-
Notifications
You must be signed in to change notification settings - Fork 31
/
Dockerfile
102 lines (84 loc) · 4.03 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
FROM python:3.8-slim
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
# Install packages needed to run your application (not build deps):
# mime-support -- for mime types when serving static files
# postgresql-client -- for running database commands
# We need to recreate the /usr/share/man/man{1..8} directories first because
# they were clobbered by a parent image.
RUN set -ex \
&& RUN_DEPS=" \
locales \
libpcre3 \
mime-support \
default-mysql-client \
libmariadb3 \
libmagic1 \
tar \
gzip \
bzip2 \
p7zip-full \
xz-utils \
gettext \
" \
&& seq 1 8 | xargs -I{} mkdir -p /usr/share/man/man{} \
&& apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \
&& rm -rf /var/lib/apt/lists/*
# Copy in your requirements file
ADD requirements.txt /requirements.txt
# ADD requirements_prod.txt /requirements_prod.txt
# OR, if you’re using a directory for your requirements, copy everything (comment out the above and uncomment this if so):
# ADD requirements /requirements
# Install build deps, then run `pip install`, then remove unneeded build deps all in a single step.
# Correct the path to your production requirements file, if needed.
RUN set -ex \
&& BUILD_DEPS=" \
build-essential \
libpcre3-dev \
libpq-dev \
default-libmysqlclient-dev \
default-mysql-client \
" \
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
&& pip install -U virtualenv \
&& python3 -m virtualenv /venv \
&& /venv/bin/pip install -U pip \
&& /venv/bin/pip install --no-cache-dir -r /requirements.txt \
&& /venv/bin/pip install --no-cache-dir dj_database_url==0.5.0 \
&& /venv/bin/pip install --no-cache-dir uwsgi \
# && /venv/bin/pip install --no-cache-dir -r /requirements_prod.txt \
\
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /var/log/anytask
RUN chmod a+w /var/log/anytask
# Copy your application code to the container (make sure you create a .dockerignore file if any large files or directories should be excluded)
RUN mkdir /code/
ADD . /code/
#ADD dependencies /
#ADD docker_entrypoint.sh /code/
WORKDIR /code/anytask
# uWSGI will listen on this port
EXPOSE 8000
EXPOSE 3031
# Add any static environment variables needed by Django or your settings file here:
ENV DJANGO_SETTINGS_MODULE=settings_docker
# Call collectstatic (customize the following line with the minimal environment variables needed for manage.py to run):
#RUN /venv/bin/python manage.py collectstatic --noinput
RUN DATABASE_URL='mysql://user:pass@db/app_db' /venv/bin/python manage.py collectstatic --settings=settings_docker --noinput --no-post-process
RUN DATABASE_URL='mysql://user:pass@db/app_db' /venv/bin/python manage.py compilemessages --settings=settings_docker
# Tell uWSGI where to find your wsgi file (change this):
ENV UWSGI_WSGI_FILE=wsgi.py
# Base uWSGI configuration (you shouldn't need to change these):
ENV UWSGI_VIRTUALENV=/venv UWSGI_HTTP=:8000 UWSGI_SOCKET=:3031 UWSGI_MASTER=1 UWSGI_HTTP_AUTO_CHUNKED=1 UWSGI_HTTP_KEEPALIVE=1 UWSGI_UID=1000 UWSGI_GID=2000 UWSGI_LAZY_APPS=1 UWSGI_WSGI_ENV_BEHAVIOR=holy
# Number of uWSGI workers and threads per worker (customize as needed):
ENV UWSGI_WORKERS=16 UWSGI_THREADS=24
# uWSGI static file serving configuration (customize or comment out if not needed):
ENV UWSGI_STATIC_EXPIRES_URI=".*\.(css|js|png|jpg|jpeg|gif|ico|woff|ttf|otf|svg|scss|map|txt) 315360000"
# Deny invalid hosts before they get to Django (uncomment and change to your hostname(s)):
# ENV UWSGI_ROUTE_HOST="^(?!localhost:8000$) break:400"
RUN rm -rf /var/log/anytask/*
# Uncomment after creating your docker-entrypoint.sh
ENTRYPOINT ["/code/docker_entrypoint.sh"]
# Start uWSGI
CMD ["/venv/bin/uwsgi", "--show-config", "--static-map", "/static/=/var/lib/anytask/static", "--static-map", "/media/=/var/lib/anytask/media", "--mime-file", "mime.types", "--mime-file", "/etc/mime.types"]