-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (40 loc) · 1.4 KB
/
Copy pathDockerfile
File metadata and controls
55 lines (40 loc) · 1.4 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
FROM node:25-alpine AS frontend-build
WORKDIR /build
COPY frontend/ /build
COPY Cargo.toml /tmp/Cargo.toml
RUN VERSION=$(awk -F'"' '/^version[[:space:]]*=/{print $2; exit}' /tmp/Cargo.toml) && \
test -n "$VERSION" && \
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"${VERSION}\"/" package.json && \
yarn && \
yarn test run && \
yarn build
FROM rust:1.98.0-alpine AS app-build
WORKDIR /build
RUN mkdir -p /build/static && \
apk add elfutils pkgconfig perl make upx openssl-dev openssl-libs-static
COPY Cargo.toml Cargo.lock /build/
COPY .cargo/ /build/.cargo/
COPY src/ /build/src/
COPY migrations/ /build/migrations/
COPY test-data/ /build/test-data/
COPY config.yml-dist /build/config.yml-dist
COPY --from=frontend-build /build/build/ /build/static/
RUN cargo test --lib && \
cargo test --bin server && \
cargo build --bin server --release && \
eu-elfcompress target/release/server && \
strip target/release/server && \
upx -9 --lzma target/release/server && \
chmod +x target/release/server
FROM alpine:3.24
WORKDIR /app
RUN apk update && \
addgroup -g 10001 app && \
adduser -h /app -D -u 10001 -G app app && \
chmod 700 /app && \
chown -R app: /app
COPY --from=app-build /build/config.yml-dist /app/config.yml
COPY --from=app-build /build/target/release/server /app/shortly
RUN chown -R app: /app && chmod +x /app/shortly
USER app
CMD ["/app/shortly"]