generated from rexzhang/python-project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathDockerfile
55 lines (48 loc) · 1.85 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
FROM python:3.13-alpine
ARG DEV_ENV
ENV TZ="Asia/Shanghai"
ENV UID=1000
ENV GID=1000
ENV WEBDAV_HOST="0.0.0.0"
ENV WEBDAV_PORT="8000"
ENV WEBDAV_CONFIGFILE="/data/webdav.json"
ENV WEBDAV_LOGGING_LEVEL="INFO"
RUN if [ "$DEV_ENV" = "rex" ]; then echo "Change depends" \
&& pip config set global.index-url https://proxpi.h.rexzhang.com/index/ \
&& pip config set install.trusted-host proxpi.h.rexzhang.com \
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
; fi
COPY docker /app
COPY requirements /app/requirements
COPY asgi_webdav /app/asgi_webdav
RUN \
# install build's depends ---
apk add --no-cache --virtual .build-deps build-base libffi-dev openldap-dev \
&& pip install --no-cache-dir -r /app/requirements/docker.txt \
# cleanup ---
&& apk del .build-deps \
&& rm -rf /root/.cache \
&& find /usr/local/lib/python*/ -type f -name '*.py[cod]' -delete \
&& find /usr/local/lib/python*/ -type d -name "__pycache__" -delete \
# LDAP client's depends ---
&& apk add --no-cache libsasl libldap \
# create non-root user ---
&& apk add --no-cache shadow su-exec\
&& addgroup -S -g $GID runner \
&& adduser -S -D -G runner -u $UID -s /bin/sh runner \
# support timezone ---
&& apk add --no-cache tzdata \
# fix libexpat bug:
# out of memory: line 1, column 0
# https://bugs.launchpad.net/ubuntu/+source/python-xmltodict/+bug/1961800
&& apk add 'expat>2.4.7' \
# prepare ---
&& mkdir /data
WORKDIR /app
VOLUME /data
EXPOSE 8000
CMD [ "/app/entrypoint.sh" ]
LABEL org.opencontainers.image.title="ASGI WebDAV Server"
LABEL org.opencontainers.image.authors="Rex Zhang"
LABEL org.opencontainers.image.url="https://hub.docker.com/repository/docker/ray1ex/asgi-webdav"
LABEL org.opencontainers.image.source="https://github.com/rexzhang/asgi-webdav"