django-simple-deploy
django-simple-deploy copied to clipboard
Refine Fly.io deployment process
trafficstars
Proof of concept Fly.io deployment is working, but there's lots left to do in order to ensure as few errors as possible.
- [x] Make initial Fly.io documentation.
- [ ] Prioritize refinements below.
- [ ] Implement most important set of refinements.
Tasks
- [x] Add a
.dockerignorefile?! #117- I believe this was important in my original (non-simple_deploy) push, because it was pushing the venv. See recent blog post.
- [ ] Run with user logged out of flyctl.
- [x] Run with a user who has created multiple apps on Fly.io.
- [ ] Re-running command
- [x] If user has attempted a push, current approach to finding app name fails.
- [ ] Consider using flag for deployed_app_name, like in Platform.sh work.
- [ ] Consider looking in current fly.toml file.
- [ ] Allow a flag for deployed app name. Should probably be same flag that platform_sh uses.
- [ ] Database management
- [x] Handle the situation where a database is found better. Make a paid account, and use simple_deploy on a second app with a current one deployed.
- [x] Reconsider when initial steps are taken, ie should we create the database after simple_deploy is added to req.txt? It may fail, so it should come before modifying the project (current reasoning).
- [x] Would really be nice to log the creation of the database and the deployed project.
- [ ] I may be making
output_strvariables that aren't ever used, ie in_create_db(). - [x] Clarify how credentials such as db connection info is shown, and logged.
- [x] Can easily recognize when a db with a matching name exists, ie
app_nameandapp_name-db.
- [ ] Dockerfile
- [ ] We can write any Python-optimized Dockerfile we want. What optimizations should this have over what Fly.io suggests? See Will's example, inspired by Jeff.
- [ ] Parse a pre-existing docker file.
- [ ] Parse a pre-existing fly.toml file.
- [ ] Refactoring
- [ ] Generalize the code for generating a new file from a template. Right now it's
_add_dockerfile()and_add_flytoml_file(), but these methods are almost identical, and the same goes for Platform.sh files such asroutes.yaml, and Heroku'sProcfile. - [ ] Make template names consistent. Either call them ie
fly_toml,fly_dockerfile, or (better) have a directory for each platform, sofly/fly.toml,fly/dockerfile,heroku/Procfile.
- [ ] Generalize the code for generating a new file from a template. Right now it's
- [ ] Builder app
- [ ] Builder app, created from a previous deploy, does not see secrets associated with current app. How address this? In test deploy, I'm going to destroy the builder app and hope a new one gets created.
- [ ] Seems to be working without running collectstatic; is that reliable? How are static files being managed?
- [ ] Is gunicorn handling all of this, and it would be more efficient to set up whitenoise?
- [ ] Messages
- [x] Review all messages for copyedit.
- [x] Remove any Platform.sh cruft from deploy_messages_flyio.py.
- [ ] Consider refactoring messages between the three platforms, ie success messages?
- [ ] Use
fly_ioandflyioconsistently. - [ ] Use
flyctlconsistently.
- [ ] Testing
- [ ] Write integration tests.
- [ ] Write unit tests.
More tasks
- [ ] Make a more specific
ALLOWED_HOSTSentry. - [x] Output of
fly deployshould stream, rather than being dumped after success. #121- [x] I believe this can be implemented using
execute_command()in simple_deploy.py, instead ofexecute_subp_run().
- [x] I believe this can be implemented using
- [ ] Fake, or don't call
fly secretswhen unit testing. - [ ] Consider IDE-specific cruft such as
.idea/and.vscodeto.dockerignore. - [ ] Is there any indication including a
.dockerignorefile has any effect on the deployment process? Can I measure the impact, in image size or deployment/ subsequent push time? - [ ] See recent blog post and recent updates to flyio docs for anything else that could be improved.
Notes/ resources
- [ ] See Twitter discussion re
psycpog2vspsycopg2-binary, and appropriate docker images/ dockerfiles. - [ ] Review against @wsvincent's latest tutorial.
- [ ] Deploy the blog project using these steps, and compare the generated Dockerfile and fly.toml to what we're using here.
- [ ] How are static files handled in this approach?
- [ ] Does
fly launchcreate a postgres db?
For now I'd just go with psycopg2-binary. More than enough for most projects. @webology would agree. Also, Psycopg 3 support is coming soon, maaaaybe for Django 4.2 if you just want to wait.
Recent work addresses most of this issue.