Production Deployment

Step 1: Prepare Environment Variables

Ensure that necessary environment variables are set before deployment. For example, define TEST_DIR that will be used by Docker Compose to bind mount volumes. This can be done as follows in a .env file:

TEST_DIR=/path/to/your/project/data

Step 2: Define Docker Compose Configuration

Modify or review the docker-compose.yml to ensure it specifies services and volumes correctly. The example below outlines a basic configuration for running a frontend service with NGINX:

version: '3.8'
services:
  frontend:
    image: nginx
    container_name: frontend
    volumes:
      - project-data:/data

volumes:
  project-data:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: "${TEST_DIR}"

Step 3: Build the Docker Image

Use the provided Dockerfile to build your application. The build process can be executed via terminal:

docker build -t your-image-name .

Ensure that the build context is set correctly, pointing to the directory containing the Dockerfile.

Step 4: Use Makefile for Build and Linting

The Makefile contains several available functions. To build the project and perform linting, run:

make build
make lint

This can help catch any issues early in the deployment process.

Step 5: Test your Application

Before deploying, thoroughly run your tests. The Makefile includes an e2e target for end-to-end testing:

make e2e

This executes your defined end-to-end tests to ensure everything is functioning as expected.

Step 6: Deploy to Production

Once the image is built, it’s time to deploy. Use Docker Compose to bring up the service.

docker-compose up -d

This command will run the services defined in the docker-compose.yml file in detached mode.

Step 7: Monitoring and Logs

To monitor the logs and status of your services, you can use:

docker-compose logs -f

This command streams the logs from your container, allowing you to verify that everything is functioning correctly post-deployment.

Step 8: Managing Containers

If you need to stop the services later, use:

docker-compose down

This command will shut down all the running services defined in your Docker Compose setup.

Conclusion

This document outlines the steps to deploy a project using Docker and Docker Compose for production environments. Following these steps ensures that your application is built and runs smoothly in a containerized setup.

Source: Provided code snippets and definitions.