Skip to content

Commit

Permalink
Merge pull request #289 from hpi-sam/252-completely-automatic-server-…
Browse files Browse the repository at this point in the history
…deployment

252 completely automatic server deployment
  • Loading branch information
Wolkenfarmer authored Jun 17, 2024
2 parents 6b9ba53 + 1a178f3 commit 1e04565
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<prod/dev>` 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.<prod/dev>).
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.<prod/dev>` 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 <username> -p <token>
```
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.<prod/dev> down --volumes
```
Expand All @@ -37,7 +39,8 @@ docker-compose --env-file .env.<prod/dev> pull
docker-compose --env-file .env.<prod/dev> 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.<prod/dev>` file on the server is enough, but fot the frontend the
Expand Down
23 changes: 22 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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"

Expand Down

0 comments on commit 1e04565

Please sign in to comment.