Skip to content

Commit

Permalink
Add Docker Action
Browse files Browse the repository at this point in the history
add docker action file

Modify docker-compose.prod.yml to use environment variables instead of
.env files
  • Loading branch information
BraunRudolf committed Jul 27, 2024
1 parent 9bc9148 commit f5b64a7
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 46 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Docker

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build-containers:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Build and run the container
env:
FASTAPI_SECRET_KEY: ${{secrets.FASTAPI_SECRET_KEY}}
FASTAPI_HASH_ALGORITHM: ${{secrets.FASTAPI_HASH_ALGORITHM}}
ACCESS_TOKEN_EXPIRE_MINUTES: ${{secrets.ACCESS_TOKEN_EXPIRE_MINUTES}}
USER_DB_URL: ${{secrets.USER_DB_URL}}
FILE_DB_URL: ${{secrets.FILE_DB_URL}}
POSTGRES_USER: ${{secrets.POSTGRES_USER}}
POSTGRES_PASSWORD: ${{secrets.POSTGRES_PASSWORD}}
POSTGRES_DB: ${{secrets.POSTGRES_DB}}
NEXT_PUBLIC_ENVIRONMENT: ${{secrets.NEXT_PUBLIC_ENVIRONMENT}}
NEXT_PUBLIC_API_URL: ${{secrets.NEXT_PUBLIC_API_URL}}
run: |
docker-compose -f docker-compose.prod.yml build
sleep 10
docker-compose -f docker-compose.prod.yml up --abort-on-container-exit
68 changes: 22 additions & 46 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,32 @@
services:
frontend:
build:
context: ./frontend-app/
dockerfile: Dockerfile
networks:
- my_network
ports:
- "3000:3000"
depends_on:
- backend
env_file:
- frontend.env

backend:
build:
context: ./backend-app/
dockerfile: Dockerfile
networks:
- my_network
image: your_backend_image
environment:
- FASTAPI_SECRET_KEY
- FASTAPI_HASH_ALGORITHM
- ACCESS_TOKEN_EXPIRE_MINUTES
- USER_DB_URL
- FILE_DB_URL
ports:
- "8000:8000"
depends_on:
- userdb
- filedb
env_file:
- backend.env

userdb:
image: postgres:13
database:
image: postgres:latest
environment:
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_DB
volumes:
- userdb_data:/var/lib/postgresql/data
ports:
- "5433:5432"
networks:
- my_network
env_file:
- database.env
filedb:
image: postgres:13
volumes:
- filedb_data:/var/lib/postgresql/data
- postgres_data:/var/lib/postgresql/data

frontend:
image: your_frontend_image
environment:
- NEXT_PUBLIC_ENVIRONMENT
- NEXT_PUBLIC_API_URL
ports:
- "5432:5432"
networks:
- my_network
env_file:
- database.env
- "3000:3000"

volumes:
userdb_data:
filedb_data:
postgres_data:

networks:
my_network:
driver: bridge

0 comments on commit f5b64a7

Please sign in to comment.