-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
65 lines (56 loc) · 2.06 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
FROM debian:latest
########################################
# Settings #
########################################
# Syncthing-Discovery Server
ENV SERV_PORT 22026
ENV DISCO_OPTS ""
########################################
# Setup #
########################################
ENV USERNAME discosrv
ENV USERGROUP discosrv
ENV APPUID 1000
ENV APPGID 1000
ENV USER_HOME /home/discosrv
ENV BUILD_REQUIREMENTS curl openssl
ENV REQUIREMENTS ca-certificates
########################################
########################################
# Build #
########################################
ARG VERSION="v1.23.4"
ARG DOWNLOADURL="https://github.com/syncthing/discosrv/releases/download/v1.23.4/stdiscosrv-linux-amd64-v1.23.4.tar.gz"
ARG BUILD_DATE="2024-10-07T12:10:18Z"
########################################
USER root
ENV DEBIAN_FRONTEND noninteractive
# setup
RUN apt-get update -qqy \
&& apt-get -qqy --no-install-recommends install ${BUILD_REQUIREMENTS} ${REQUIREMENTS} \
&& mkdir -p ${USER_HOME} \
&& groupadd --system --gid ${APPGID} ${USERGROUP} \
&& useradd --system --uid ${APPUID} -g ${USERGROUP} ${USERNAME} --home ${USER_HOME} \
&& echo "${USERNAME}:$(openssl rand 512 | openssl sha256 | awk '{print $2}')" | chpasswd \
&& chown -R ${USERNAME}:${USERGROUP} ${USER_HOME}
# install disco
WORKDIR /tmp/
RUN curl -Ls ${DOWNLOADURL} --output discosrv.tar.gz \
&& tar -zxf discosrv.tar.gz \
&& rm discosrv.tar.gz \
&& mkdir -p ${USER_HOME}/server ${USER_HOME}/certs ${USER_HOME}/db \
&& cp /tmp/*discosrv*/*discosrv ${USER_HOME}/server/discosrv \
&& chown -R ${USERNAME}:${USERGROUP} ${USER_HOME}
# cleanup
RUN apt-get --auto-remove -y purge ${BUILD_REQUIREMENTS} \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*
EXPOSE ${SERV_PORT}
USER discosrv
VOLUME ${USER_HOME}/certs
CMD ${USER_HOME}/server/discosrv \
-listen=":${SERV_PORT}" \
-db-dir="${USER_HOME}/db/discosrv.db" \
-cert="${USER_HOME}/certs/cert.pem" \
-key="${USER_HOME}/certs/key.pem" \
${DISCO_OPTS}