Skip to content

Commit 95c01b2

Browse files
committed
Add docker-compose for production environment
1 parent 7153cc2 commit 95c01b2

File tree

7 files changed

+149
-0
lines changed

7 files changed

+149
-0
lines changed

app/.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**/bundle/
2+
**/node_modules/
3+
**/webpack-stats.json
4+
5+
**/*.sqlite3
6+
**/.env
7+
**/junitxml/
8+
**/staticfiles/
9+
**/venv/
10+
**/__pycache__/

app/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM python:3.6
2+
3+
# set work directory
4+
WORKDIR /app
5+
6+
# set environment variables
7+
ENV PYTHONDONTWRITEBYTECODE 1
8+
ENV PYTHONUNBUFFERED 1
9+
10+
# install psycopg2 dependencies
11+
RUN apt-get update \
12+
&& apt-get install --no-install-recommends -y python3-dev libpq-dev unixodbc-dev
13+
14+
# install dependencies
15+
RUN pip install --upgrade pip setuptools
16+
COPY ./requirements.txt /app/requirements.txt
17+
RUN pip install --no-cache-dir -r requirements.txt
18+
19+
# copy project
20+
COPY . /app/

app/requirements.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apache-libcloud==2.4.0
2+
applicationinsights==0.11.7
3+
coverage==4.5.3
4+
dj-database-url==0.5.0
5+
Django==2.1.7
6+
django-cloud-browser==0.5.0
7+
django-filter==2.0.0
8+
django-heroku==0.3.1
9+
django-webpack-loader==0.6.0
10+
django-widget-tweaks==1.4.2
11+
django-polymorphic==2.0.3
12+
django-pyodbc-azure==2.1.0.0
13+
django-rest-polymorphic==0.1.8
14+
djangorestframework==3.8.2
15+
djangorestframework-csv==2.1.0
16+
djangorestframework-filters==0.10.2
17+
environs==4.1.0
18+
djangorestframework-xml==1.4.0
19+
Faker==0.9.1
20+
flake8==3.6.0
21+
furl==2.0.0
22+
gunicorn==19.9.0
23+
lockfile==0.12.2
24+
mixer==6.1.3
25+
model-mommy==1.6.0
26+
psycopg2-binary==2.7.7
27+
python-dateutil==2.7.3
28+
pytz==2018.4
29+
requests==2.21.0
30+
six==1.11.0
31+
seqeval==0.0.6
32+
social-auth-app-django==3.1.0
33+
social-auth-core[azuread]==3.0.0
34+
text-unidecode==1.2
35+
tornado==5.0.2
36+
unittest-xml-reporting==2.5.1
37+
vcrpy==2.0.1
38+
vcrpy-unittest==0.1.7
39+
whitenoise[brotli]==4.1.2
40+
conllu==1.3.2

app/tools/run.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
5+
echo "Initializing database"
6+
python manage.py wait_for_db
7+
python manage.py migrate
8+
# python manage.py create_roles
9+
10+
if [[ -n "${ADMIN_USERNAME}" ]] && [[ -n "${ADMIN_PASSWORD}" ]] && [[ -n "${ADMIN_EMAIL}" ]]; then
11+
python manage.py create_admin \
12+
--username "${ADMIN_USERNAME}" \
13+
--password "${ADMIN_PASSWORD}" \
14+
--email "${ADMIN_EMAIL}" \
15+
--noinput \
16+
|| true
17+
fi
18+
19+
echo "Starting django"
20+
gunicorn --bind 0.0.0.0:8000 app.wsgi --timeout 300

docker-compose.prod.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: "3"
2+
services:
3+
4+
backend:
5+
build: ./app
6+
command: ["/app/tools/run.sh", "0.0.0.0:8000"]
7+
volumes:
8+
- ./app/:/app/
9+
environment:
10+
ADMIN_USERNAME: "admin"
11+
ADMIN_PASSWORD: "password"
12+
ADMIN_EMAIL: "[email protected]"
13+
DATABASE_URL: "postgres://doccano:doccano@postgres:5432/doccano?sslmode=disable"
14+
ALLOW_SIGNUP: "False"
15+
ports:
16+
- 8000:8000
17+
depends_on:
18+
- postgres
19+
20+
nginx:
21+
build: ./nginx
22+
volumes:
23+
- static_volume:/home/app/web/staticfiles
24+
ports:
25+
- 1337:80
26+
depends_on:
27+
- backend
28+
29+
postgres:
30+
image: postgres:12.0-alpine
31+
volumes:
32+
- postgres_data:/var/lib/postgresql/data/
33+
environment:
34+
POSTGRES_USER: "doccano"
35+
POSTGRES_PASSWORD: "doccano"
36+
POSTGRES_DB: "doccano"
37+
ports:
38+
- 5432:5432
39+
40+
volumes:
41+
postgres_data:
42+
static_volume:

nginx/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM nginx:1.17.4-alpine
2+
3+
RUN rm /etc/nginx/conf.d/default.conf
4+
COPY nginx.conf /etc/nginx/conf.d

nginx/nginx.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
server {
2+
listen 80;
3+
charset utf-8;
4+
5+
location /v1/ {
6+
proxy_pass http://backend:8000/v1/;
7+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
8+
proxy_set_header Host $host;
9+
proxy_redirect off;
10+
}
11+
}
12+
13+
server_tokens off;

0 commit comments

Comments
 (0)