diff --git a/README.md b/README.md index 020f9588..49b44b0e 100644 --- a/README.md +++ b/README.md @@ -20,14 +20,16 @@ There are two environment files provided with the docker-compose file in the art The `.env.prod` file is used for the production version on a server and the `.env.dev` file is used for the development version locally. Replace `` with `prod` or `dev` in the following commands to use the respective environment file. 0. Prerequisites: Install Docker and Docker Compose on the server where you want to deploy the software. -1. Download the action artifacts and extract them in a folder +1. Download the action artifacts and extract them in a folder. Alternatively, you can manually copy the needed files from the repo (. + /docker-compose.yml, ./.env.). 2. Recommended: As the env files are probably stored in a public repository, it is strongly encouraged to change the SECRET_KEY and the POSTGRES_PASSWORD variables in the used `.env.` file. 3. Log into the GitHub Packages registry with the following command. Ask a team member for valid credentials. ```bash docker login ghcr.io -u -p ``` -4. Optional: If you want a clean start, run following command in that folder in order to recreate the database: +4. Optional: If you want a clean start and have the application already running, execute following command in that folder in order to recreate the + database: ```bash docker-compose --env-file .env. down --volumes ``` @@ -37,7 +39,8 @@ docker-compose --env-file .env. pull docker-compose --env-file .env. up ``` -The application is now deployed and the website should be accessible on port 5173. +The application is now deployed and the website should be accessible on port 5173. The images will be automatically updated on each release and +the containers restarted accordingly. Keep in mind that the IP address of the server running the back- and frontend are hardcoded in the environment files. For the backend a simple correction of the `FRONTEND_URL` variable within the `.env.` file on the server is enough, but fot the frontend the diff --git a/docker-compose.yml b/docker-compose.yml index 9c6e62fa..1286e83f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,21 @@ version: '3.8' services: + # Update service for self-hosted Docker images for completely automatic deployment + # Only updates images marked with the label "com.centurylinklabs.watchtower.enable=true" + watchtower: + image: containrrr/watchtower + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /root/.docker/config.json:/config.json + command: --interval 60 --label-enable + # Database service postgres: image: ghcr.io/hpi-sam/dps_training_k-postgres:${IMAGE_TAG} container_name: K-dPS-postgres + labels: + - "com.centurylinklabs.watchtower.enable=true" env_file: - .env.${RUN_CONFIG} volumes: @@ -18,13 +29,15 @@ services: # Caching service redis: - image: redis:latest + image: redis:7.2.5 container_name: K-dPS-redis # Backend service django: image: ghcr.io/hpi-sam/dps_training_k-django:${IMAGE_TAG} container_name: K-dPS-django + labels: + - "com.centurylinklabs.watchtower.enable=true" restart: unless-stopped depends_on: - postgres @@ -43,6 +56,8 @@ services: celeryworker: image: ghcr.io/hpi-sam/dps_training_k-celeryworker:${IMAGE_TAG} container_name: K-dPS-celeryworker + labels: + - "com.centurylinklabs.watchtower.enable=true" depends_on: - django env_file: @@ -53,6 +68,8 @@ services: celerybeat: image: ghcr.io/hpi-sam/dps_training_k-celerybeat:${IMAGE_TAG} container_name: K-dPS-celerybeat + labels: + - "com.centurylinklabs.watchtower.enable=true" depends_on: - django env_file: @@ -63,6 +80,8 @@ services: nginx: image: ghcr.io/hpi-sam/dps_training_k-nginx:${IMAGE_TAG} container_name: K-dPS-nginx + labels: + - "com.centurylinklabs.watchtower.enable=true" depends_on: - django volumes: @@ -74,6 +93,8 @@ services: web: image: ghcr.io/hpi-sam/dps_training_k-frontend:${IMAGE_TAG} container_name: K-dPS-frontend + labels: + - "com.centurylinklabs.watchtower.enable=true" ports: - "5173:5173"