-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
81 lines (70 loc) · 2.07 KB
/
Dockerfile
File metadata and controls
81 lines (70 loc) · 2.07 KB
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
ARG ENV=dev
FROM node:alpine as node
# RUN apk update && apk --no-cache add build-base python2 libsass
WORKDIR /code/
COPY ./yarn.lock /code
COPY ./package.json /code
RUN yarn --frozen-lockfile
FROM python:3.9-alpine as builder
ARG ENV
ENV DJANGO_ENV ${ENV}
WORKDIR /code/
RUN apk update && apk --no-cache add python3 \
build-base \
python3-dev \
# wget dependency
openssl \
openssl-dev \
# dev dependencies
git \
bash \
sudo \
py3-pip \
# Pillow dependencies
jpeg-dev \
zlib-dev \
freetype-dev \
libsass-dev \
lcms2-dev \
openjpeg-dev \
tiff-dev \
tk-dev \
tcl-dev \
harfbuzz-dev \
fribidi-dev \
# cryptography dependencies
cargo \
# Postgres dependencies
postgresql-dev
# Install any needed packages specified by Poetry
RUN pip install poetry
COPY ./pyproject.toml /code
COPY ./poetry.lock /code
RUN echo ${ENV}; [ "x${DJANGO_ENV}" = "xdev" ] \
&& poetry export --dev -f requirements.txt > requirements.txt \
|| poetry export -f requirements.txt > requirements.txt
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /wheels -r requirements.txt
FROM python:3.9-alpine as runner
LABEL maintainer="solarliner@gmail.com"
# Set environment varibles
ARG ENV
ARG PORT=8000
ENV PYTHONUNBUFFERED 1
ENV DJANGO_ENV ${ENV}
ENV DJANGO_SETTINGS_MODULE codeanon.settings.${ENV}
WORKDIR /code
RUN apk update && apk add --no-cache libpq jpeg zlib tiff tk tcl openjpeg libsass
COPY . /code/
COPY --from=node /code/node_modules /code/node_modules
COPY --from=builder /wheels /wheels
RUN pip install --no-cache --no-deps --no-index /wheels/*
RUN rm -rf /wheels
RUN SECRET_KEY="tempkey" sh -c "\
python manage.py compilescss && \
python manage.py collectstatic --noinput --clear --ignore='*.sass' --ignore='*.scss'"
RUN adduser -S wagtail && chown -R wagtail /code
USER wagtail
EXPOSE ${PORT}
HEALTHCHECK --start-period=10s --interval=30s --timeout=3s --retries=3\
CMD wget -nv --header="Accept: application/json" --header="Host: $DJANGO_HOST" -t1 "http://localhost:$PORT/healthcheck" -O- || exit 1
CMD ./docker_entry.sh gunicorn codeanon.wsgi:application --workers=3 --bind=0.0.0.0:$PORT