In this exercise we'll learn how you can configure tasks to depend on each other.
Note
If you haven't installed docker, no problem. There are two ways to solve it:
- go to https://www.docker.com/products/docker-desktop/ and install docker-desktop to your system. that's it
- exchange the deploy command in the movies project.json with
echo 'thanks for deploying with austrian airlines'
. This is cheap, but works.
Please delete the dist
folder from your machine.
Run the deploy
command for the movies
app.
execute deploy
npx nx run movies:deploy
You will notice that it fails, as it requires to the dist
folder to be present!
If you open the task graph for the movies:deploy
target, you'll notice that is has no dependencies at all.
Run deploy task graph
npx nx run movies:deploy --graph
So our main pain point here is that build
is not getting executed before deploy
is executed.
We are going to fix that soon ;).
Go to either the nx.json
or the apps/movies/project.json
file and configure the deploy
target to { "dependsOn" : ["build"] }
Now let's execute the deploy
command again.
execute deploy
npx nx run movies:deploy
You should see that it'll execute build
before it does execute deploy
.
If you open the task graph for the movies:deploy
target, you'll notice that it now has dependencies!
Run deploy task graph
npx nx run movies:deploy --graph
Note
The workshop is for you! So that you can get familiar with new tools. If you feel like playing around, go ahead and finish this exercise as well.
e.g. build depends on lint & test or just deploy depends on build test & lint
This task has a very abstract description: Just go ahead and configure other constraints that make sense to you. You can always validate what you did by watching the task graph!