Skip to content

Commit e8bdcb7

Browse files
Init dockerization
1 parent 8347705 commit e8bdcb7

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-0
lines changed

docker-compose.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
version: "3.9"
2+
3+
services:
4+
db:
5+
image: postgres:13.2
6+
environment:
7+
- POSTGRES_DB=styleguide_example_db
8+
- POSTGRES_USER=postgres
9+
- POSTGRES_PASSWORD=postgres
10+
11+
django:
12+
build:
13+
context: .
14+
dockerfile: docker/local.Dockerfile
15+
command: python manage.py runserver 0.0.0.0:8000
16+
environment:
17+
- DATABASE_URL=postgres://postgres:postgres@db:5432/styleguide_example_db
18+
- CELERY_BROKER_URL=redis://redis
19+
volumes:
20+
- .:/app
21+
ports:
22+
- "8000:8000"
23+
depends_on:
24+
- db
25+
- redis
26+
restart: on-failure
27+
28+
celery:
29+
build:
30+
context: .
31+
dockerfile: docker/local.Dockerfile
32+
command: celery --app=styleguide_example.tasks.celery worker --without-gossip --without-heartbeat --without-mingle --loglevel=info
33+
environment:
34+
- DATABASE_URL=postgres://postgres:postgres@db:5432/styleguide_example_db
35+
- CELERY_BROKER_URL=redis://redis
36+
volumes:
37+
- .:/app
38+
depends_on:
39+
- db
40+
- redis
41+
restart: on-failure
42+
43+
beats:
44+
build:
45+
context: .
46+
dockerfile: docker/local.Dockerfile
47+
command: celery --app=styleguide_example.tasks.celery beat --loglevel=info
48+
environment:
49+
- DATABASE_URL=postgres://postgres:postgres@db:5432/styleguide_example_db
50+
- CELERY_BROKER_URL=redis://redis
51+
volumes:
52+
- .:/app
53+
depends_on:
54+
- db
55+
- redis
56+
restart: on-failure
57+
58+
redis:
59+
image: "redis:alpine"

docker/local.Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Creating image based on official python3 image
2+
FROM python:3.9.4
3+
4+
# Fix python printing
5+
ENV PYTHONUNBUFFERED 1
6+
7+
# Installing all python dependencies
8+
ADD requirements/ requirements/
9+
RUN pip install -r requirements/local.txt
10+
11+
# Get the django project into the docker container
12+
RUN mkdir /app
13+
WORKDIR /app
14+
ADD ./ /app/

docker/production.Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Creating image based on official python3 image
2+
FROM python:3.9.4
3+
4+
# Installing all python dependencies
5+
ADD requirements/ requirements/
6+
RUN pip install -r requirements/production.txt
7+
8+
# Get the django project into the docker container
9+
RUN mkdir /app
10+
WORKDIR /app
11+
ADD ./ /app/

docker/web_entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
echo "--> Starting web app"
2+
gunicorn config.wsgi:application -b 0.0.0.0:80

requirements/base.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ djangorestframework==3.13.1
66
celery==5.2.3
77
django-celery-results==2.2.0
88
django-celery-beat==2.2.1
9+
celery[redis]
910

1011
whitenoise==5.3.0
1112

0 commit comments

Comments
 (0)