A dockerized Razzle and NestJS project template in TypeScript.
I created this template for a project that I'm currently working on.
-
Clone the repository.
-
Build all containers using
docker-compose build --no-cache
. -
Run all containers using
docker-compose up
.Notes: When running docker compose, it will create new volume(s). If change(s) are made to
package.json
, it won't be detected by the container. I recommend:- To remove the volume
docker volume prune
, or - Update package manually by doing
docker exec -it <container id> sh
andnpm install
I use the
--no-cache
flag so that new npm packages gonna be installed.Tips:
- Use
--build
indocker-compose
to force update the docker image created, e.g.docker-compose up --build
- To remove the volume
-
Viewing website: In
docker-compose.yml
, I map the Nginx container's port :80 to your localhost port :1337. To see if this is working, visit http://localhost:1337. -
Connecting to API server: In the Nginx's
default.conf
, I filter calls to/api
to the backend. You can then use Postman or curl to test routes e.g. http://localhost:1337/api/users. -
Connecting to a shell in container: If you want shell access to a particular docker container, execute the following command:
# Lists all running containers with their names docker ps # Connects a shell session to a running container docker exec -it <container_name> <command (either sh or /bin/bash)>
-
When you're done,
Ctrl-C
in the maindocker-compose up
window to terminate the running processes. -
Run
docker-compose down
to stop and remove containers.
Copyright (c) 2019 Veri Ferdiansyah
Licensed under the MIT license.