Django on Docker development challenges

I finally had some time to do some deep work yesterday, and go my unversity project’s Django instance up and running. It took way to long. The local version settings for Cookiecutter Django work very easy from a Docker setup, but deploying them to a production instance took me by surprise. There were several issues I had to work through.

Cloud storage: I had inadvertently setup my project with the cloud storage settings for AWS. We’re not using either AWS or Google Cloud Services for CDN since this is just a small prototype. Since we didn’t have the AWS bucket credentials, the Django service wouldn’t start. I had to replay my setttings file to recreate my project without cloud services set to none. I attempted to use a fork of CC Django that uses Ngnix as the media server, but had other issues with it and decided we just won’t have media for this prototype.

Traefix: The production settings put Django behind a Traefik load balancer firewall, it’s configured to use Let’sEncrypt! for validation. Leaving this section blank causes Traefik to fail. So I commented out the SSL validation section of the configuration file. Currently it throws a warning about a nonexistent validator, but this is the only way to get it to serve pages. Currently. I’ll register with Let’sEncrypt!, but I’m not sure I’ll be able to procure a cert for our web server given that it’s a host on our University’s CS domain.

Developmental environment issues: Perhaps the most frustrating problems I’m having are around the way our environment is setup. I work off campus, yet our resource host is only available inside the campus network. I’m using our CS Gitlab server as a code repo, but I haven’t setup and CI jobs to deploy the code yet. On order for me to terminal to the server I have to SSH to our public CS server, then SSH to the resource server. In order to view the Django website, I have to open an RDS session. Not ideal, but I’ve yet to optimize the setup.

And troubleshooting these various problems with our production server comes with it’s own set of challenges. The git repo is synced to our Docker host, and the instance is deployed via docker-compose commands. In order for me to update the code, I have to cycle through down, build and up commands to resync the code. Hopefully, I’ll be able to setup Pycharm’s Docker remote capabilities to edit the code directly within the docker instance. We had planned to setup multiple containers in order to run a test server, but that’s going to be very difficult on a single host.

I’ve had other minor issues with production settings not taking properly. It looks like the .env files aren’t loading properly, causing the default local ones to be imported. I had to change the defaults in, but I assume this may break our local setup.

When everything is shaped up, I’ll have one git repo that can be run locally, in test or production, with a CI job that will deploy commits to our Docker container. I’ve got a lot of work to do.

Leave a Reply

Your email address will not be published. Required fields are marked *