-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDockerfile
88 lines (75 loc) · 2.7 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
FROM debian:latest
########################################
# Settings #
########################################
# Syncthing-Relay Server
ENV DEBUG false
ENV SERVER_PORT 22067
ENV RELAY_OPTS ""
# to enable the status interface add ' -p 22070:22070' to you docker command
ENV STATUS_PORT 22070
# 10 mbps
ENV RATE_GLOBAL 10000000
# 500 kbps
ENV RATE_SESSION 500000
ENV TIMEOUT_MSG 1m45s
ENV TIMEOUT_NET 3m30s
ENV PING_INT 1m15s
ENV PROVIDED_BY "syncthing-relay"
# leave empty for private relay use "https://relays.syncthing.net/endpoint" for public relay
ENV POOLS ""
########################################
# Setup #
########################################
ARG USERNAME=relaysrv
ARG USERGROUP=relaysrv
ARG APPUID=1000
ARG APPGID=1000
ENV USER_HOME /home/relaysrv
ARG BUILD_REQUIREMENTS="curl"
ARG REQUIREMENTS="openssl ca-certificates"
########################################
########################################
# Build #
########################################
ARG VERSION="v1.22.1"
ARG DOWNLOADURL="https://github.com/syncthing/relaysrv/releases/download/v1.22.1/strelaysrv-linux-amd64-v1.22.1.tar.gz"
ARG BUILD_DATE="2023-11-17T13:40:11Z"
########################################
USER root
ARG 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 relay
WORKDIR /tmp/
RUN curl -Ls ${DOWNLOADURL} --output relaysrv.tar.gz \
&& tar -zxf relaysrv.tar.gz \
&& rm relaysrv.tar.gz \
&& mkdir -p ${USER_HOME}/server ${USER_HOME}/certs \
&& cp /tmp/*relaysrv*/*relaysrv ${USER_HOME}/server/relaysrv \
&& 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 ${STATUS_PORT} ${SERVER_PORT}
USER $USERNAME
VOLUME ${USER_HOME}/certs
CMD ${USER_HOME}/server/relaysrv \
-keys="${USER_HOME}/certs" \
-listen=":${SERVER_PORT}" \
-status-srv=":${STATUS_PORT}" \
-debug="${DEBUG}" \
-global-rate="${RATE_GLOBAL}" \
-per-session-rate="${RATE_SESSION}" \
-message-timeout="${TIMEOUT_MSG}" \
-network-timeout="${TIMEOUT_NET}" \
-ping-interval="${PING_INT}" \
-provided-by="${PROVIDED_BY}" \
-pools="${POOLS}" ${RELAY_OPTS}