-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile-simple
49 lines (36 loc) · 1.46 KB
/
Dockerfile-simple
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
# Quicker docker build that assumes the application has already been built in the local directory.
# Might be useful for some debugging purposes, but in general we recommend using the regular Dockerfile
# which does a full clean build.
# Prerequisites:
# npm install
# grunt build
# Remove "target" from .dockerignore
# Then:
# docker build . -t clusive -f Dockerfile-simple
# docker run -p 8000:8000 -e DJANGO_CONFIG=local clusive
FROM python:3.7-alpine as base
# No point caching bytecode for single run
ENV PYTHONDONTWRITEBYTECODE 1
# Don't buffer log output inside the container
ENV PYTHONUNBUFFERED 1
COPY requirements.txt /
RUN \
apk add --no-cache postgresql-libs git gcc musl-dev postgresql-dev npm && \
python -m pip install -r /requirements.txt --no-cache-dir
# Don't run as root
RUN mkdir -p /app /home/app
RUN addgroup -S app && adduser -S -G app app && chown app /app /home/app
USER app
WORKDIR /app
RUN python -m nltk.downloader wordnet
COPY --chown=app target .
COPY src/entrypoint.sh .
RUN python manage.py collectstatic --no-input
EXPOSE 8000
STOPSIGNAL SIGINT
ENTRYPOINT ["/app/entrypoint.sh"]
HEALTHCHECK --interval=10s --timeout=3s \
CMD wget --quiet --tries=1 --spider http://localhost:8000/ || exit 1
# gunicorn configuration suggestions from https://pythonspeed.com/articles/gunicorn-in-docker/
CMD ["gunicorn", "clusive_project.wsgi", "--bind=0.0.0.0:8000", "--worker-tmp-dir=/dev/shm", \
"--workers=2", "--threads=4", "--worker-class=gthread"]