-
-
Save projectoperations/9f69a4b27fbf5e29513b2db5b18bbb29 to your computer and use it in GitHub Desktop.
GitHub actions + Docker Compose example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CI overrides | |
version: '3' | |
services: | |
web: | |
environment: | |
- DATABASE_URL | |
- DJANGO_SETTINGS_MODULE | |
- SECRET_KEY | |
- PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Local dev overrides | |
version: '3' | |
services: | |
web: | |
env_file: | |
- .env | |
# This was the offending line | |
volumes: | |
- ~/app_name/:/code | |
postgres: | |
volumes: | |
- pgdata:/var/lib/postgresql/data | |
volumes: | |
pgdata: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# base configuration | |
version: '3' | |
services: | |
web: | |
container_name: backend | |
build: . | |
ports: | |
- "${PORT}:8000" | |
depends_on: | |
- postgres | |
postgres: | |
container_name: postgres | |
image: postgres | |
restart: always | |
environment: | |
- POSTGRES_PASSWORD=${PG_PASS} | |
ports: | |
- 5432:5432 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GitHub Actions configuration | |
name: Docker Image CI | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
PG_PASS: ${{ secrets.PG_PASS }} | |
DATABASE_URL: postgresql://postgres:${{ secrets.SECRET_PASSWORD }}@postgres/postgres | |
DJANGO_SETTINGS_MODULE: app_name.settings.dev | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
PORT: 8000 | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Build the docker-compose stack | |
run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d | |
- name: Check running containers | |
run: docker ps -a | |
- name: Check logs | |
run: docker logs backend | |
- name: Run test suite | |
run: docker exec backend pytest --skip-auth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment