This repository provides a Makefile to simplify the management of the DHIS2 Docker Swarm environment. The Makefile includes commands for Docker Swarm operations, as well as volume management and cleanup.
For detailed information about the DHIS2 Docker Swarm environment itself, please refer to SWARM.md.
Disclaimer: This codebase is intended for testing and demonstration purposes only. It is not designed or reviewed for production use. Use at your own risk.
- Docker installed on your system
- Docker Swarm initialized on your system
The application requires environment files to run properly:
.env.swarm: Contains environment variables for the Docker Swarm setup- Copy from
.env.swarm.example:cp .env.swarm.example .env.swarm - Database credentials are loaded from secrets, not from this file
- Copy from
This file is mandatory for the application to run properly and is ignored by git to prevent committing sensitive information.
These commands manage the DHIS2 environment using Docker Swarm:
-
Initialize Docker Swarm secrets:
make swarm-init-secrets
This creates Docker Swarm secrets from files in the
./secretsdirectory. -
Deploy the stack to Docker Swarm:
make swarm-deploy
This includes creating secrets and deploying the stack.
-
Remove the stack from Docker Swarm:
make swarm-remove
This also removes the Docker Swarm secrets.
-
Update the stack in Docker Swarm:
make swarm-update
-
Rebuild images and update the stack:
make swarm-rebuild
-
List all volumes used by the stack:
make volume-list
-
Remove all unused volumes:
make volume-prune
This will prompt for confirmation before removing volumes.
- Remove the stack, secrets, and secret files in root directory:
make clean
- Show help message with all available commands:
make help
For Docker Swarm deployment, the following secrets are required in the ./secrets directory:
postgres-user: PostgreSQL usernamepostgres-password: PostgreSQL passwordpostgres-db: PostgreSQL database namecredentials: DHIS2 credentials file (contains database username, password, and encryption password)
# Initialize Docker Swarm (if not already done)
docker swarm init
# Deploy the stack
make swarm-deploy
# Check stack status
docker stack services dhis2
# Remove the stack
make swarm-removeIf you encounter issues with the Docker Swarm commands, check the following:
- Ensure Docker is properly installed
- Ensure Docker Swarm is initialized
- Check that all required secret files exist in the
./secretsdirectory - Verify that you have created the required environment file:
.env.swarmfor Docker Swarm mode
- Review the logs for any error messages
For more detailed information about the DHIS2 Docker Swarm environment, including configuration and upgrading components, please refer to SWARM.md.