cookiecutter-django icon indicating copy to clipboard operation
cookiecutter-django copied to clipboard

Supporting Digital Ocean App platform flows

Open Jihad opened this issue 2 years ago • 2 comments

Description

Digital Ocean new app-platform offers seamless production deployment from github. Currently creating an app and linking a "cookie-cutter Django" github repo, shows an error of "no detected components" due to the files structure (I assume).

Rationale

This could help a lot in increasing adoption and make production updates for cookie-cutter django much smoother for small (or one-man) teams.

TBF not sure if it's an issue that should be here or with DO support, but I figured to mention it to you guys if you liked the idea.

Jihad avatar May 13 '22 10:05 Jihad

I believe a similar/related discussion is here on https://github.com/Koed00/django-q/issues/522

Jihad avatar May 13 '22 10:05 Jihad

If that's possible with not too many changes, then maybe, yes.

Currently creating an app and linking a "cookie-cutter Django" github repo, shows an error of "no detected components" due to the files structure (I assume).

What option have you selected to get this error? As far as I can tell, if you choose docker=n & heroku=y it might work according to their Python guide.

I glanced quickly over their docs, and think there a few things to answer/clarify with Docker:

  1. To run an app using docker, DO needs a Dockerfile at the root of the repo, which we don't provide. We would need to point DO to our Dockerfile running the django server.
  2. Do we need Traefik or is it handled by DO? I would assume the latter
  3. With Docker + Celery, we'll have more than one Dockerfile, so I'm not sure how that would work. Something to explore?
  4. The database is fully managed with that? So again, no need for a Dockerfile for postgres...

At first glance, it looks quite simialr to Heroku, where one deploys the app and the other related services (DB, Redis, ...) are managed. If that's a correct assumption, then I suggest to not support Docker + DO (at least at first). if you can clear these concern in a vanilla cookiecutter-django project and report back here, that would be very helpful in making a decision.

PS: this is all under the condition that the extra-maintenance effort is very small. If the amount of files/documentation to maintain is significant, I'd rather not do it. This project is maintained by volunteers and I'd rather not spend too much time customising for another platform.

browniebroke avatar May 13 '22 13:05 browniebroke

All you need is a requirements.txt file in the root with the following content:

-r requirements/production.txt

which seems to be present in the newer versions

jTiKey avatar Feb 07 '23 12:02 jTiKey

How does digital ocean know the entry point of the app? How does it know what to run?

How does it work with Celery?

Do we need to describe any specific steps in some cases? Front-end assets compilation, DB migrations...

browniebroke avatar Feb 07 '23 13:02 browniebroke

The run command needs to be manually changed to:

"gunicorn --worker-tmp-dir /dev/shm config.wsgi"

It doesn't work with celery. They have their own "Function" feature that could replace celery tasks.

Automatically, It installs requirements.txt and runs collectstatic. Migrations and other manage.py need to be run manually using their console.

jTiKey avatar Feb 07 '23 13:02 jTiKey

It looks like there isn't much more we can do in the generated project. Most config seems to happen in their apps dashboard and they have plenty of documentation explaining what to do.

Unless I'm missing something, I suggest we close this issue.

browniebroke avatar Feb 07 '23 14:02 browniebroke

Agreed, it should be closed.

The project I'm trying to deploy is old and didn't have requirements.txt generated, hence I was getting the "no detected components" error. Since it's being generated in the current version, this error should not show up anymore.

jTiKey avatar Feb 07 '23 14:02 jTiKey

This file has been there for a very long time, I don't think it's because your project is old. It's probably not there because you chose heroku=n, the file is removed in this case:

https://github.com/cookiecutter/cookiecutter-django/blob/dc68912c07b649d40f7ecd2f7ec45b1a10deb3c6/hooks/post_gen_project.py#L74-L84

browniebroke avatar Feb 07 '23 14:02 browniebroke

Most likely! It was deployed on a digitalocean droplet which doesn't need the heroku options.

jTiKey avatar Feb 07 '23 14:02 jTiKey