This project consists of three main services:
- db: Database service using PostgreSQL.
- api: Backend rest api built with Node.js and express.
- web: Frontend web app built with React and vite.
Rename the .env.example
file to .env
and update the values according to your environment.
HOST_NAME=host.docker.internal
DB_NAME=your_db_name
DB_USER=your_db_user
DB_PSWD=your_db_user_password
DB_PORT=your_db_server_port ex. 5432
API_PORT=your_rest_api_port ex. 4000
WEB_PORT=your_web_app_port ex. 3000
DB_CONN=${DB_USER}:${DB_PSWD}@${HOST_NAME}:${DB_PORT}/${DB_NAME}
API_CONN=${HOST_NAME}:${API_PORT}
First of all, make sure your postgres service is running on your local machine
Run the following command to start the database, api and web servers:
yarn dev
Run the following command to build the project:
yarn build
Run the following command to start the server:
yarn start
docker compose --env-file .env up --build -d
docker compose stop
docker compose start
docker compose down
Both taskify-db
and taskify-api
services includes a health check to ensure it is ready before the dependents services starts.
The depends_on
condition is set to service_healthy
to ensure the current service waits for its dependencies services to be ready.
source .env
Run this command only once to create a custom network for services communication:
docker network create taskify-standalone-network
Run the following command to build the Docker images:
docker build -t img-taskify-db-standalone:latest ./database \
--build-arg DB_USER=${DB_USER} \
--build-arg DB_PSWD=${DB_PSWD} \
--build-arg DB_NAME=${DB_NAME}
docker build -t img-taskify-api-standalone:latest ./packages/api \
--build-arg DB_CONN=${DB_CONN} \
--build-arg API_PORT=${API_PORT}
docker build -t img-taskify-web-standalone:latest ./packages/web \
--build-arg API_CONN=${API_CONN} \
--build-arg WEB_PORT=${WEB_PORT}
Run the following command to start the database container:
docker run -d --name db.taskify-standalone.io \
-p ${DB_PORT}:${DB_PORT} \
-v taskify_db_data_standalone:/var/lib/postgresql/data \
--network taskify_standalone_network \
img-taskify-db-standalone:latest
Run the following command to start the api container:
docker run -d --name api.taskify-standalone.io \
-p ${API_PORT}:${API_PORT} \
--network taskify_standalone_network \
img-taskify-api-standalone:latest
Run the following command to start the web container:
docker run -d --name web.taskify-standalone.io \
-p ${WEB_PORT}:${WEB_PORT} \
--network taskify_standalone_network \
img-taskify-web-standalone:latest
Run the following commands to restart a container given it's name:
docker restart bd.taskify-standalone.io
docker restart api.taskify-standalone.io
docker restart web.taskify-standalone.io
Ensure that the environment variables are correctly set in .env
file at repository root, and that the services are
properly configured to communicate over the same network.
Also, when running with docker, you may need to include the following entry to your /etc/hosts
file of your host machine:
127.0.0.1 host.docker.internal