Created
August 13, 2017 01:35
-
-
Save nolram/58244e203865b914cc0b14b64391741f to your computer and use it in GitHub Desktop.
Docker-compose: Django + Postgis + RabbitMQ + Celery + Redis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
# Postgis | |
db: | |
image: mdillon/postgis | |
hostname: db | |
environment: | |
POSTGRES_USER: "postgres" | |
POSTGRES_PASSWORD: "docker" | |
# Redis | |
redis: | |
image: redis:3.2.8 | |
hostname: redis | |
# RabbitMQ | |
rabbit: | |
hostname: rabbit | |
image: rabbitmq:3.6.9 | |
environment: | |
- RABBITMQ_DEFAULT_USER=admin | |
- RABBITMQ_DEFAULT_PASS=mypass | |
ports: | |
- "5672:5672" | |
- "15672:15672" | |
# Django | |
web: | |
build: | |
context: . | |
dockerfile: Dockerfile | |
hostname: web | |
command: ./run_web.sh | |
volumes: | |
- .:/code:Z | |
ports: | |
- "8000:8000" | |
links: | |
- db | |
- rabbit | |
- redis | |
depends_on: | |
- db | |
# Celery worker | |
worker: | |
build: | |
context: . | |
dockerfile: Dockerfile | |
command: ./run_celery.sh | |
volumes: | |
- .:/code:Z | |
links: | |
- db | |
- rabbit | |
- redis | |
depends_on: | |
- rabbit | |
# Celery worker | |
beat: | |
build: | |
context: . | |
dockerfile: Dockerfile | |
command: ./run_celery_beat.sh | |
volumes: | |
- .:/code:Z | |
links: | |
- worker | |
- db | |
- rabbit | |
- redis | |
depends_on: | |
- worker | |
- rabbit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.5 | |
MAINTAINER Marlon Baptista de Quadros([email protected]) | |
ENV PYTHONUNBUFFERED 1 | |
RUN apt-get update -y | |
RUN apt-get -y install binutils libproj-dev gdal-bin postgresql-client python3-lxml | |
RUN apt-get -y install libmemcached-dev | |
RUN mkdir /code | |
WORKDIR /code | |
ADD requirements.txt /code/ | |
RUN pip install -r requirements.txt | |
ADD . /code/ | |
# create unprivileged user | |
RUN adduser --disabled-password --gecos '' myuser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
django==1.10.5 | |
Pillow==4.0.0 | |
djangorestframework==3.5.3 | |
psycopg2==2.6.2 | |
django-filter==1.0.1 | |
Markdown==2.6.8 | |
requests==2.13.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# wait for RabbitMQ server to start | |
sleep 10 | |
# Replace * with name of Django Project | |
su -m myuser -c "celery worker -A *.celery -l info" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# wait for RabbitMQ server to start | |
sleep 10 | |
su -m myuser -c "rm /tmp/celerybeat-doshi.pid > /dev/null" | |
# Replace * with name of Django Project | |
su -m myuser -c "celery beat -A *.celery -l info --pidfile=/tmp/*.pid" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# wait for PSQL server to start | |
sleep 10 | |
su -m myuser -c "python manage.py makemigrations" | |
su -m myuser -c "python manage.py migrate" | |
su -m root -c "python manage.py runserver 0.0.0.0:8000" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment