-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.ssh
More file actions
58 lines (42 loc) · 1.63 KB
/
Dockerfile.ssh
File metadata and controls
58 lines (42 loc) · 1.63 KB
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
# ================================
# Build SSH Server
# ================================
FROM swift:6.3-bookworm AS ssh-server-builder
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
&& apt-get -q update \
&& apt-get -q dist-upgrade -y \
&& apt-get install -y libjemalloc-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY ./Package.* ./
RUN swift package resolve \
$([ -f ./Package.resolved ] && echo "--force-resolved-versions" || true)
COPY . .
RUN swift build -c release \
--product SiteSSHServer \
--static-swift-stdlib \
-Xlinker -ljemalloc
WORKDIR /staging
RUN cp "$(swift build --package-path /build -c release --show-bin-path)/SiteSSHServer" ./
RUN find -L "$(swift build --package-path /build -c release --show-bin-path)/" -regex '.*\.resources$' -exec cp -Ra {} ./ \;
# ================================
# Deploy
# ================================
FROM debian:bookworm-slim
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
&& apt-get -q update \
&& apt-get -q dist-upgrade -y \
&& apt-get -q install -y \
libjemalloc2 \
ca-certificates \
tzdata \
libcurl4 \
&& rm -r /var/lib/apt/lists/*
RUN useradd --user-group --create-home --system --skel /dev/null --home-dir /server deploy
WORKDIR /server
COPY --from=ssh-server-builder --chown=deploy:deploy /staging /server
ENV SWIFT_BACKTRACE=enable=yes,sanitize=yes,threads=all,images=all,interactive=no,swift-backtrace=./swift-backtrace-static
USER deploy:deploy
EXPOSE 2222
ENTRYPOINT ["./SiteSSHServer"]
CMD ["--hostname", "0.0.0.0", "--port", "2222"]