Skip to content

This repository contains the source code for a task management web application, developed as an assignment for my graduate program in Software Architecture. The project is built using PostgreSQL, TypeScript, Express, and React, and is fully Dockerized for easy deployment and development.

Notifications You must be signed in to change notification settings

lidia-freitas/taskify-app

Repository files navigation

taskify-logo.png

Overview

This project consists of three main services:

  1. db: Database service using PostgreSQL.
  2. api: Backend rest api built with Node.js and express.
  3. web: Frontend web app built with React and vite.

Prerequisites

Environment Variables

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}

Running services on localhost for development


First of all, make sure your postgres service is running on your local machine

1. Start the Server

Run the following command to start the database, api and web servers:

  yarn dev

Running the services on localhost in production preview mode


1. Build the Project

Run the following command to build the project:

  yarn build

2. Start the Server

Run the following command to start the server:

  yarn start

Running the services with Docker Compose


1. Build and start all services:

  docker compose --env-file .env up --build -d

2. Stop services containers:

  docker compose stop

3. Restart services containers:

  docker compose start

4. Stop and remove all the containers, networks, and volumes:

  docker compose down

Health Check

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.

Running each service individually with Docker (standalone)


1. Load the environment variables

  source .env

1. Create a Custom Docker Network

Run this command only once to create a custom network for services communication:

  docker network create taskify-standalone-network

2. Build the Docker images

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} 

3. Run the containers

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

4. Re-start the Containers

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

Troubleshooting

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

About

This repository contains the source code for a task management web application, developed as an assignment for my graduate program in Software Architecture. The project is built using PostgreSQL, TypeScript, Express, and React, and is fully Dockerized for easy deployment and development.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published