Skip to content

Commit

Permalink
Streamline docker setup a bit more (#264)
Browse files Browse the repository at this point in the history
* docker: Take user creation off developers' shoulders

* docker: Turn mysite/celery.py into a static file

* readme: Advertise 127.0.0.1 rather than (working but weird) 0.0.0.0
  • Loading branch information
hartwork authored and auvipy committed Jun 10, 2019
1 parent c9f21ce commit 90a1a3f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ pip command::
Developing django-celery-beat
-----------------------------

To spin up a local development copy of django-celery-beat with Django admin at http://0.0.0.0:58000/admin/ run::
To spin up a local development copy of django-celery-beat with Django admin at http://127.0.0.1:58000/admin/ run::

$ docker-compose build
$ docker-compose run django python3 manage.py createsuperuser
$ docker-compose up
$ docker-compose up --build

Log-in as user ``admin`` with password ``admin``.


TZ Awareness:
Expand Down
6 changes: 3 additions & 3 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN apt-get update && apt-get install --yes --no-install-recommends \

RUN pip3 install --user \
celery \
django-createsuperuserwithpassword \
psycopg2-binary

COPY setup.cfg setup.py /app/
Expand All @@ -32,7 +33,6 @@ WORKDIR /mysite/
RUN echo 'DATABASES = {"default": {"ENGINE": "django.db.backends.postgresql", "NAME": "postgres", "USER": "postgres", "HOST": "postgres", "PORT": 5432}}' >> mysite/settings.py
RUN echo 'ALLOWED_HOSTS = ["*"]' >> mysite/settings.py
RUN echo 'INSTALLED_APPS += ("django_celery_beat", )' >> mysite/settings.py
RUN echo 'INSTALLED_APPS += ("django_createsuperuserwithpassword", )' >> mysite/settings.py

RUN echo 'from celery import Celery' > mysite/celery.py
RUN echo 'import os; os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")' >> mysite/celery.py
RUN echo 'app = Celery("mysite")' >> mysite/celery.py
COPY docker/base/celery.py mysite/celery.py
10 changes: 10 additions & 0 deletions docker/base/celery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (C) 2019 Sebastian Pipping <[email protected]>
# Licensed under the BSD License (3 clause, also known as the new BSD license)

import os

from celery import Celery

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')

app = Celery('mysite')
6 changes: 6 additions & 0 deletions docker/django/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ wait-for-it postgres:5432

python3 manage.py migrate

python3 manage.py createsuperuserwithpassword \
--username admin \
--password admin \
--email [email protected] \
--preserve

exec "$@"

0 comments on commit 90a1a3f

Please sign in to comment.