-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
51 lines (34 loc) · 1.24 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
FROM node:22.9.0-alpine3.20 as frontend-build
ARG FALLBACK_LOCALE_ID=en
WORKDIR /build
COPY frontend/ /build
RUN sed -i "s/'en'/'$FALLBACK_LOCALE_ID'/g" /build/src/routes/+layout.ts && \
yarn && \
yarn build
FROM rust:1.83.0-alpine3.20 as app-build
WORKDIR /build
RUN mkdir -p /build/static && \
apk add nodejs npm musl-dev elfutils xz wget pkgconfig libressl-dev perl make && \
wget https://github.com/upx/upx/releases/download/v4.0.2/upx-4.0.2-amd64_linux.tar.xz && \
unxz upx-4.0.2-amd64_linux.tar.xz && tar xvf upx-4.0.2-amd64_linux.tar && \
cp upx-4.0.2-amd64_linux/upx /usr/bin/upx && chmod +x /usr/bin/upx
COPY . /build
COPY --from=frontend-build /build/build/ /build/static/
COPY favicon.png /build/static/
RUN cargo test && \
cargo build --release && \
eu-elfcompress target/release/pw && \
strip target/release/pw && \
upx -9 --lzma target/release/pw && \
chmod +x target/release/pw
FROM alpine:3.20.3
WORKDIR /app
RUN apk add libressl-dev && \
adduser -h /app -D pw && \
chmod 700 /app && \
chown -R pw: /app
COPY --from=app-build /build/pw.yml-dist /app/pw.yml
COPY --from=app-build /build/target/release/pw /app/pw
RUN chown -R pw: /app && chmod +x /app/pw
USER pw
CMD ["/app/pw"]