-
Notifications
You must be signed in to change notification settings - Fork 72
/
Dockerfile
59 lines (56 loc) · 1.99 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
FROM python:3.11-alpine3.19 AS builder
COPY ./package_list.txt /tmp/
COPY ./requirements.txt /tmp/
RUN apk add --no-cache --virtual .build-deps \
libffi-dev \
gcc \
musl-dev \
libxml2-dev \
libxslt-dev \
&& apk add --no-cache $(cat /tmp/package_list.txt) \
&& curl https://rclone.org/install.sh | bash \
&& if [ "$(uname -m)" = "x86_64" ]; then ARCH=amd64; elif [ "$(uname -m)" = "aarch64" ]; then ARCH=arm64; fi \
&& curl https://dl.min.io/client/mc/release/linux-${ARCH}/mc --create-dirs -o /usr/bin/mc \
&& chmod +x /usr/bin/mc \
&& pip install --upgrade pip setuptools wheel \
&& pip install cython \
&& pip install gunicorn \
&& pip install -r /tmp/requirements.txt \
&& apk del --purge .build-deps \
&& rm -rf /tmp/* /root/.cache /var/cache/apk/*
COPY --chmod=755 ./docker/rootfs /
FROM scratch AS app
COPY --from=Builder / /
ENV S6_SERVICES_GRACETIME=30000 \
S6_KILL_GRACETIME=60000 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_SYNC_DISKS=1 \
HOME="/nt" \
TERM="xterm" \
PATH=${PATH}:/usr/lib/chromium \
LANG="C.UTF-8" \
TZ="Asia/Shanghai" \
NASTOOL_CONFIG="/config/config.yaml" \
PS1="\u@\h:\w \$ " \
PYPI_MIRROR="https://pypi.tuna.tsinghua.edu.cn/simple" \
ALPINE_MIRROR="mirrors.ustc.edu.cn" \
PUID=0 \
PGID=0 \
UMASK=000 \
NT_PORT=3000 \
WORKDIR="/nas-tools"
RUN mkdir ${WORKDIR}
ADD ./ ${WORKDIR}/
WORKDIR ${WORKDIR}
RUN mkdir ${HOME} \
&& addgroup -S nt -g 911 \
&& adduser -S nt -G nt -h ${HOME} -s /bin/bash -u 911 \
&& echo 'fs.inotify.max_user_watches=5242880' >> /etc/sysctl.conf \
&& echo 'fs.inotify.max_user_instances=5242880' >> /etc/sysctl.conf \
&& echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf \
&& echo "nt ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
HEALTHCHECK --interval=30s --timeout=30s --retries=3 \
CMD wget -qO- http://localhost:${NT_PORT}/healthcheck || exit 1
EXPOSE 3000
VOLUME ["/config"]
ENTRYPOINT [ "/init" ]