-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
66 lines (56 loc) · 2.61 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
FROM python:3.10-slim
ENV APP_DIR=/virtual_library_card/ \
DJANGO_SETTINGS_MODULE=virtual_library_card.settings.prod \
POETRY_VIRTUALENVS_CREATE=false
ENV UWSGI_MASTER=1 \
UWSGI_HTTP_AUTO_CHUNKED=1 \
UWSGI_HTTP_KEEPALIVE=1 \
UWSGI_LAZY_APPS=1 \
UWSGI_WSGI_ENV_BEHAVIOR=holy \
UWSGI_WORKERS=2 \
UWSGI_THREADS=4 \
UWSGI_WSGI_FILE=$APP_DIR/virtual_library_card/wsgi.py \
UWSGI_HTTP=:8000 \
UWSGI_UID=999 \
UWSGI_GID=999 \
UWSGI_DIE_ON_TERM=true \
UWSGI_HARAKIRI=20 \
UWSGI_MAX_REQUESTS=5000 \
UWSGI_VACUUM=true \
UWSGI_POST_BUFFERING=1 \
UWSGI_LOGFORMAT="[pid: %(pid)|app: -|req: -/-] %(addr) (%(user)) {%(vars) vars in %(pktsize) bytes} [%(ctime)] %(method) %(clean_uri) => generated %(rsize) bytes in %(msecs) msecs (%(proto) %(status)) %(headers) headers in %(hsize) bytes (%(switches) switches on core %(core))"
# required for postgres ssl: the crt file doesn't exist
# but the path must point to a visible directory otherwise we
# get a permissions error
ENV PGSSLCERT=/tmp/postgresql.crt
ARG POETRY_VERSION=1.7.1
ARG REPO=ThePalaceProject/virtual-library-card
# Install system
RUN apt-get update -y && \
apt-get install --no-install-recommends -y \
curl mime-support libexpat1 && \
curl -sSL https://install.python-poetry.org | POETRY_HOME="/opt/poetry" python3 - --yes --version "$POETRY_VERSION" && \
ln -s /opt/poetry/bin/poetry /bin/poetry && \
apt-get autoremove -y && \
rm -Rf /var/lib/apt/lists/* && \
rm -Rf /root/.cache && \
find /opt /usr -type d -name "__pycache__" -exec rm -rf {} +
WORKDIR $APP_DIR
# Do basic python dependency install
# We use curl here to grab our poetry.lock and pyproject.toml files from the repo
# so that we can cache the docker layer for the poetry install step.
# If these files change, the later poetry install will handle it.
RUN curl -fsSL https://raw.githubusercontent.com/${REPO}/main/pyproject.toml -o ${APP_DIR}pyproject.toml && \
curl -fsSL https://raw.githubusercontent.com/${REPO}/main/poetry.lock -o ${APP_DIR}poetry.lock && \
poetry install --sync --only main --no-root --no-interaction && \
poetry cache clear -n --all pypi && \
rm -Rf /root/.cache && \
find /opt /usr -type d -name "__pycache__" -exec rm -rf {} +
# Do final poetry install, when the layers are cached, this is the only step that will run
COPY . $APP_DIR
RUN POETRY_VIRTUALENVS_CREATE=false poetry install --sync --only main --no-interaction && \
poetry cache clear -n --all pypi && \
rm -Rf /root/.cache && \
find /opt /usr -type d -name "__pycache__" -exec rm -rf {} +
EXPOSE 8000
CMD ["./entrypoint.sh"]