Videos
Hi everybody!
From time to time I see posts or comments by people asking how to deploy their Django app on their server. I thought I'd share my process here. If you have any questions or ideas for improvements, share them here or contact me on Twitter/X.
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.