-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
125 lines (95 loc) · 4.02 KB
/
Copy pathDockerfile
File metadata and controls
125 lines (95 loc) · 4.02 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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# ================================
# Build CV
# ================================
FROM debian:bookworm-slim as cv-builder
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
&& apt-get -q update \
&& apt-get -q install -y --no-install-recommends \
latexmk \
lmodern \
texlive-latex-base \
texlive-latex-recommended \
texlive-latex-extra \
texlive-fonts-recommended \
texlive-fonts-extra \
texlive-plain-generic \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY resume/cv.tex resume/styling.sty ./
RUN mkdir -p .output \
&& latexmk -pdf -interaction=nonstopmode -outdir=.output -jobname=mobile-resume \
-pdflatex='pdflatex %O "\def\showmobile{}\input{%S}"' cv.tex \
&& latexmk -pdf -interaction=nonstopmode -outdir=.output -jobname=web-resume \
-pdflatex='pdflatex %O "\def\showweb{}\input{%S}"' cv.tex \
&& latexmk -pdf -interaction=nonstopmode -outdir=.output -jobname=swift-resume \
-pdflatex='pdflatex %O "\def\showswift{}\input{%S}"' cv.tex \
&& latexmk -pdf -interaction=nonstopmode -outdir=.output -jobname=resume \
-pdflatex='pdflatex %O "\def\showmobile{}\def\showweb{}\input{%S}"' cv.tex \
&& rm -f .output/*.aux .output/*.log .output/*.out .output/*.fdb_latexmk .output/*.fls
# ================================
# Base swift build
# ================================
FROM swift:6.3-bookworm AS 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 \
--static-swift-stdlib \
-Xlinker -ljemalloc
RUN BIN_PATH="$(swift build -c release --show-bin-path)" \
&& mkdir -p /staging/site-server /staging/ssh-server \
&& cp "$BIN_PATH/SiteServer" /staging/site-server/ \
&& cp "$BIN_PATH/SiteSSHServer" /staging/ssh-server/ \
&& find -L "$BIN_PATH" -regex '.*SiteServer.*\.resources$' -exec cp -Ra {} /staging/site-server/ \; \
&& find -L "$BIN_PATH" -regex '.*SiteSSHServer.*\.resources$' -exec cp -Ra {} /staging/ssh-server/ \;
# ================================
# Run site-server
# ================================
FROM debian:bookworm-slim AS site-server
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=builder --chown=deploy:deploy /staging/site-server /server
COPY --from=builder --chown=deploy:deploy /build/public ./public
COPY --from=cv-builder --chown=deploy:deploy /build/.output ./public
ENV SWIFT_BACKTRACE=enable=yes,sanitize=yes,threads=all,images=all,interactive=no,swift-backtrace=./swift-backtrace-static
USER deploy:deploy
EXPOSE 8080
ENTRYPOINT ["./SiteServer"]
CMD ["--hostname", "0.0.0.0", "--port", "8080"]
# ================================
# Run site-ssh-server
# ================================
FROM debian:bookworm-slim AS ssh-server
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=builder --chown=deploy:deploy /staging/ssh-server /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"]