This repository contains a Docker Compose configuration for setting up a PostgreSQL database and a backend service using Docker. Also it contains a GitHub Actions workflow for running Docker Compose, Logs, Tests on the backend service.
Before you begin, ensure you have the following installed on your local machine:
- Docker: Install Docker
- Docker Compose: Install Docker Compose
-
Clone this repository to your local machine:
git clone https://github.com/yourusername/your-repository.git
-
Navigate to the cloned repository:
cd your-repository
-
Create a .env file in the root directory and specify the following environment variables:
POSTGRES_USER=your_postgres_user POSTGRES_PASSWORD=your_postgres_password POSTGRES_DB=your_postgres_db POSTGRES_HOST=postgres POSTGRES_PORT=5432
-
Build and start the Docker containers using Docker Compose:
docker-compose up -d
-
Access your backend service at http://localhost:8080.
The GitHub Actions workflow defined in .github/workflows/ci-cd.yml performs the following steps:
- Sets up the Docker Compose environment.
- Builds the Docker containers.
- Starts the Docker containers.
- Displays the logs.
- Runs the tests on the backend service.
To use this workflow, you need to create a GitHub repository and push the code to the repository. The workflow will run automatically.