🌐
DEV Community
dev.to › ken_mwaura1 › beginners-guide-to-github-actions-django-and-docker-2om6
Beginners Guide to GitHub Actions, Django and Docker - DEV Community
April 3, 2023 - Finally, we run the docker-compose file to ensure no errors in container creation. Let's take a look at the YAML file. name: Zoo Django Actions on: [push] jobs: build: runs-on: ubuntu-latest strategy: max-parallel: 4 matrix: python-version: [ 3.6, 3.7, 3.8, 3.9] database-name: - zoo_django_actions database-password: - postgres database-user: - postgres database-host: - 127.0.0.1 database-port: - 5432 services: postgres: image: postgres:latest env: POSTGRES_DB: ${{ matrix.database-name }} POSTGRES_USER: ${{ matrix.database-user }} POSTGRES_PASSWORD: ${{ matrix.database-password }} ports: - 5432
🌐
GitHub
github.com › matacoder › django-docker
GitHub - matacoder/django-docker: Fast start Django with Docker and Bulma CSS (PostgreSQL, Nginx, Gunicorn)
For all other docker-related secrets you can use sole ENV secret. Run this command within project: ... That will give you string array very alike SSH key. Save it to ENV secret. Now look at workflow. RollyPeres/base64-to-path@v1 action will extract this to .env file. That is fast and reliable way to export all your environment variable at once. ... name: Django-Docker workflow on: push: branches: - master jobs: magic_deploy: name: Deploy to server with remote docker-compose runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: pytho
Starred by 16 users
Forked by 3 users
Languages   Python 54.4% | HTML 40.6% | Dockerfile 3.1% | Shell 1.9% | Python 54.4% | HTML 40.6% | Dockerfile 3.1% | Shell 1.9%
Discussions

Deploying Django with Github Actions and Docker

Cool stuff. But, unless you need to run tests, it is better to save yourself a lot of time and use a service that does it for you, for example I use Appliku.

And even if you run tests you can trigger deployment via webhook after tests finish or soemthing like that. Deployment is a bit more tricky then just clone and build the image with the app. For example what about SSL, management of env vars and all the rest?

More on reddit.com
🌐 r/django
2
14
September 3, 2023
Running Django in a Github Action so that it's accessible to React and E2E test suite
The solution I found here was to run docker-compose up -d commands to build my docker containers from our global docker-compose.yml. Doing that results in persistent containers with those services, with their ports mapped onto the bridge network. It also makes the code for my Github Actions a lot more concise. Here's what my updated Github action YML looks like: name: Test Suite on: [push] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build Postgres container run: | cp .env.frontend.template .env.frontend.dev cp .env.github_actions .env.dev docker-compose up -d db - name: Build React container run: | docker-compose up -d frontend - name: Build Django container run: | docker-compose up -d web - name: Run Django migrations run: | docker compose exec web python manage.py migrate - name: Run Django tests run: | docker compose exec web python manage.py test - name: Test active ports run: | sudo lsof -i -P -n | grep LISTEN - name: Run Cypress tests uses: cypress-io/github-action@v4 with: project: ./frontend/apps/web/ More on reddit.com
🌐 r/django
4
15
July 22, 2022
Test via Github actions?
I just saw that Github Actions nowadays allows docker-compose tests, which would allow us to fully run (aside from oracle and the likes) the Django testsuite in github actions. I think if we were a... More on github.com
🌐 github.com
4
August 24, 2019
Continuously Deploying Django to DigitalOcean with Docker and GitHub Actions

This is great. I have also read the previous article about Django and docker with postgresql, nginx and modified it to work with postgis for GeoDjango both on ubuntu and alpine. Since this article uses digital ocean managed database, if i remove the managed db and include the db part in Dockerfile (this article repo has no mention of db in Dockerfile) as discussed in previous article. Will it work in deployment as it works on my dev machine? In short I don't want to use managed db, instead I would like to use the one which is described in Dockerfile. Steps should be same? Or having database in containers will pose problems? All your articles are really great :) Thank you

More on reddit.com
🌐 r/django
11
54
April 14, 2020
🌐
Medium
medium.com › cranecloud › django-docker-and-github-actions-e9383432066f
Django, Docker, and GitHub Actions | by Derrick | Crane Cloud | Medium
October 16, 2022 - Django, Docker, and GitHub Actions Do you have a Django application? Do you want to dockerize a Django app? Do you want to set up a Continous Integration pipeline for your Django application with …
🌐
GitHub
github.com › GeoNode › django-docker › actions
Actions · GeoNode/django-docker
June 27, 2023 - GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD.
Author   GeoNode
🌐
TestDriven.io
testdriven.io › blog › deploying-django-to-digitalocean-with-docker-and-github-actions
Continuously Deploying Django to DigitalOcean with Docker and GitHub Actions | TestDriven.io
June 27, 2021 - Push the image to the Container registry on GitHub Packages: $ docker push ghcr.io/<USERNAME>/<REPOSITORY_NAME>/web:latest # example: # docker push ghcr.io/testdrivenio/django-github-digitalocean/web:latest
🌐
TestDriven.io
testdriven.io › blog › deploying-django-to-linode-with-docker-and-github-actions
Continuously Deploying Django to Linode with Docker and GitHub Actions | TestDriven.io
September 2, 2022 - Give it a name/note -- e.g., "GitHub actions" -- and add the following permissions: ... Next, click on the "Generate token" button. You're only going to be able to see the token once, so store it somewhere safe. ... $ docker build -f app/Dockerfile -t ghcr.io/<USERNAME>/<REPOSITORY_NAME>/web:latest ./app # Example $ docker build -f app/Dockerfile -t ghcr.io/testdrivenio/django-github-linode/web:latest ./app
🌐
Webscale
section.io › home › blog
Automating Tests for Dockerized Django Applications with ...
June 24, 2025 - Get the latest insights on AI, personalization, infrastructure, and digital commerce from the Webscale team and partners.
🌐
GitHub
github.com › koladev32 › django-aws-docker-github-actions
GitHub - koladev32/django-aws-docker-github-actions · GitHub
Contribute to koladev32/django-aws-docker-github-actions development by creating an account on GitHub.
Starred by 7 users
Forked by 2 users
Languages   Python 93.6% | Shell 4.2% | Dockerfile 2.2%
Find elsewhere
🌐
JetBrains
jetbrains.com › pycharm › guide › tutorials › django-aws › github-actions
GitHub Actions - JetBrains Guide
February 17, 2023 - Hello everyone, welcome to the Django tutorial series. In this tutorial step, we are going to build, tag and push our docker image to Amazon Elastic Container Registry through GitHub Actions.
🌐
GitHub
github.com › testdrivenio › django-github-digitalocean
GitHub - testdrivenio/django-github-digitalocean: Continuously Deploying Django to DigitalOcean with Docker and GitHub Actions
Configure GitHub Actions to continuously deploy a Django and Docker application to DigitalOcean.
Starred by 54 users
Forked by 43 users
Languages   Python 81.0% | Dockerfile 11.6% | Shell 7.4% | Python 81.0% | Dockerfile 11.6% | Shell 7.4%
🌐
GitHub
github.com › aamishbaloch › django_with_github_actions
GitHub - aamishbaloch/django_with_github_actions: This is a sample code for dockerizing your django application with Postgres, Nginx and Gunicorn and setting up with github actions.
This is a sample code for dockerizing your django application with Postgres, Nginx and Gunicorn and setting up with github actions. - aamishbaloch/django_with_github_actions
Forked by 2 users
Languages   Python 76.7% | Dockerfile 20.2% | Shell 2.6% | Makefile 0.5% | Python 76.7% | Dockerfile 20.2% | Shell 2.6% | Makefile 0.5%
🌐
Reddit
reddit.com › r/django › running django in a github action so that it's accessible to react and e2e test suite
r/django on Reddit: Running Django in a Github Action so that it's accessible to React and E2E test suite
July 22, 2022 -

We've got a Django+React app we're trying to get running inside a Github Action so that we can run our test suite against it. (Everything builds and runs fine in a our local docker environment)

In the Github Action, we've got Postgres running as a service inside a service: block and Django can connect to it just fine. Our Django migrations and test suite run without issue.

Now, I'm trying to get Django reachable by our React app, inside the Github Action, and run our (Cypress) end-to-end tests.

I first tried running our custom docker container for Django, but Github Actions doesn't seem to support containers not built on their base images or those from Docker hub. (Though it's possible they do and I'm just not using the right syntax.)

I then tried invoking ./manage.py runserver and backgrounding it with../manage.py 0.0.0.0:8000 & inside the block for my job, but I don't seem to be able to reach it on that port in subsequent steps.

I also experimented with creating a service for Django inside the services: block. It lets me pull a python base image from docker hub, and declare the port, but I haven't been able to find an entry point so that I can install my requirements with pip, copy over my custom apps, run the migrations, and start the server.

In Github's docs for creating services, they show examples for Postgres and Redis with only simple config provided via env vars. I'm not sure if their implementation of services: is intended for more creating more complex services with additional run steps.

Anyone have Django running in a Github Action environment in a way that your front-end JS apps and E2E tests can run against it?

Or, other suggestions or experiences to get this working on Github Actions?

I'll post our yml config in a comment below.

Top answer
1 of 2
5
The solution I found here was to run docker-compose up -d commands to build my docker containers from our global docker-compose.yml. Doing that results in persistent containers with those services, with their ports mapped onto the bridge network. It also makes the code for my Github Actions a lot more concise. Here's what my updated Github action YML looks like: name: Test Suite on: [push] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build Postgres container run: | cp .env.frontend.template .env.frontend.dev cp .env.github_actions .env.dev docker-compose up -d db - name: Build React container run: | docker-compose up -d frontend - name: Build Django container run: | docker-compose up -d web - name: Run Django migrations run: | docker compose exec web python manage.py migrate - name: Run Django tests run: | docker compose exec web python manage.py test - name: Test active ports run: | sudo lsof -i -P -n | grep LISTEN - name: Run Cypress tests uses: cypress-io/github-action@v4 with: project: ./frontend/apps/web/
2 of 2
2
Here's the YML file for our Github Action: The service created under the web: service doesn't do much at the moment, all the Django operations are run from the steps: section of the build: job. name: Test Suite on: [push] jobs: build: runs-on: ubuntu-latest services: postgres: image: postgres:13.0 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: xxxxxxxxxx POSTGRES_DB: github_actions ports: - 5432:5432 # needed because the postgres container does not provide a healthcheck options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 web: image: python:3.9-buster ports: - 8000:8000 steps: - uses: actions/checkout@v2 - name: Set up Python 3.9 uses: actions/setup-python@v2 with: python-version: 3.9 - name: Install os packages run: | sudo apt-get install build-essential libssl-dev libffi-dev python3-dev python-dev libpq-dev - name: Install dependencies run: | python3 -m pip install --upgrade pipenv pipenv install --system --deploy - name: Run migrations run: python3 my_app/manage.py migrate - name: Run tests env: SECRET_KEY: django-insecure-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx run: | cp .env.github_actions my_app/ cd my_app python3 manage.py test - uses: actions/setup-node@v3 with: node-version: 16 - name: Test persistent django run: | cd my_app python3 manage.py runserver 0.0.0.0:8000 & curl http://localhost:8000/admin/
🌐
GitHub
github.com › prakashsharmacs24 › django-docker-compose › actions
Actions · prakashsharmacs24/django-docker-compose
prakashsharmacs24 / django-doc... workflow from idea to production · GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD....
Author   prakashsharmacs24
🌐
GitHub
github.com › django › django-docker-box › issues › 9
Test via Github actions? · Issue #9 · django/django-docker-box
August 24, 2019 - I just saw that Github Actions nowadays allows docker-compose tests, which would allow us to fully run (aside from oracle and the likes) the Django testsuite in github actions. I think if we were a...
Author   apollo13
🌐
GitHub
github.com › nickjj › docker-django-example
GitHub - nickjj/docker-django-example: A production ready example Django app that's using Docker and Docker Compose. · GitHub
Besides the Django app itself: uv is used for package management instead of pip3 (builds on my machine are ~10x faster!) Docker support has been added which would be any files having *docker* in its name · GitHub Actions have been set up · You'll need to have Docker installed.
Starred by 1.5K users
Forked by 467 users
Languages   Python 37.9% | Shell 29.4% | HTML 19.2% | Dockerfile 11.2% | JavaScript 2.2% | CSS 0.1%
🌐
Medium
medium.com › intelligentmachines › github-actions-end-to-end-ci-cd-pipeline-for-django-5d48d6f00abf
GitHub Actions: End to end CI/CD Pipeline for Django | by Raju Ahmed Shetu | intelligentmachines | Medium
June 5, 2020 - 6. Create a .gitignore file and added all the necessary files and folders you don’t want in GitHub. 7. Initialize django project running django-admin startproject app . 8. We will create an app in django named users and add some tests there. Create the app using python manage.py startapp users ... 10. We need to change out database config in app/settings.py file to make sure our postgres database works. For this delete DATABASES variable in app/settings.py and paste the code below. ... 12. We will add a Dockerfile to our project directory which will build our application into an image.
🌐
DevPress
devpress.csdn.net › cloudnative › 62f0e2417e66823466183ab1.html
Beginners Guide to GitHub Actions, Django and Docker_django_weixin_0010034-云原生
August 8, 2022 - I recommend the GiHub Action documentation to get started. First thing to note is workflow files are written in YAML. This is a simple way to structure your workflow. The YAML syntax is very similar to JSON. It's beyond the scope of this guide to explain the YAML syntax. However, to get started you can use the YAML Cheatsheet. Now let's do a walk-through on adding this workflow to your project/repository: Create a new directory called .github/. Note the .
🌐
GitHub
github.com › MasterKale › Docker-Django
GitHub - MasterKale/Docker-Django: A complete Django setup, running in Docker · GitHub
Save the value of the --token flag in the page's docker command to this project's .env file as the CLOUDFLARE_TUNNEL_TOKEN environment variable · Run start-prod.sh to start the tunnel and display an entry under Connectors ... When these steps are complete, running start-prod.sh should make Django available on the public internet at https://$PROD_HOST_NAME.
Starred by 72 users
Forked by 25 users
Languages   Shell 53.9% | Dockerfile 37.4% | Python 8.7%