In the project directory, you can run:
Installs all of the required dependencies in the node_modules directory.
Runs the app in the development mode.
Runs the app in the development mode with a watcher - changes to .ts files will trigger a reload.
Runs ESLint to ensure that your code is conforming to standards.
We use Docker to containerize our application and run (at some point) on our production servers. It is a good opportunity to simulate the behavior locally before going through the rigorous task of having to test, PR, merge, build, and then deploy just to find out that your new feature doesnt work.
Running Docker locally is pretty simple, you just need to make sure that it's installed on your machine.
-
Start by navigating to your terminal
-
You can test your Docker installation by doing the following:
- Run
docker -v
to ensure that it has been installed correctly (and is a part of your PATH) - Run
docker run hello-world
to ensure that the installation appears to be working correctly
- Run
-
Run
docker build -t club-manager/server .
- This builds a Docker image based on the Dockerfile in our project directory
- It is tagged as "club-manager/server" but you can call it something else if you prefer
-
Run
docker run -d -p 4000:4000 club-manager/server
to start the container up in detached mode- If you want to observe it in the foreground directly, you need to replace
-d
with-t -i
- Refer to the docker run documentation it has lots of other options you might find useful
- If you want to observe it in the foreground directly, you need to replace
When it's time to stop the container, you can do the following.
- Run
docker ps
and node your container ID - Run
docker stop <container ID>
This functionality is much more applicable to local development. It will handle setting up a local database (MongoDB) for you to use along with a development container that is running the server.
Docker compose is another application you will need to install for this to work.
-
Navigate to your terminal
-
Run
docker-compose build
-
Run
docker-compose up
- At this point you should see via. logs that the server and database will have started up.
-
To exit you can ctrl+c and it should stop the containers.
-
When you ctrl+c out, your containers will be in the "stop" state. At this point, you can run
docker-compose start
to resume where you left off. -
Any subsequent changes to your package.json file or docker resources will require a fresh build. In this case you will need to run
docker-compose down
to clean up the containers and then rebuild. -
I highly encourage you to review the docker-compose docs, or even just run
docker-compose
to see what else you can do.