-
Notifications
You must be signed in to change notification settings - Fork 375
/
Dockerfile
63 lines (43 loc) · 1.78 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
ARG BUILDER_IMAGE=builder_cache
############################################################
# Cache image with all the deps
FROM rust:1.83-bookworm AS builder_cache
RUN rustup component add rustfmt clippy
WORKDIR /build
COPY . ./
RUN cargo fmt --all -- --check --color=always || (echo "Use cargo fmt to format your code"; exit 1)
RUN cargo clippy --all --all-features -- -D warnings || (echo "Solve your clippy warnings to succeed"; exit 1)
#RUN cargo test --all --all-features
#RUN just test "tcp://localhost:2375" || (echo "Test are failing"; exit 1)
#ENV RUSTFLAGS="-C link-arg=-Wl,--compress-debug-sections=zlib -C force-frame-pointers=yes"
RUN cargo build --tests --all-features
#RUN cargo build --release --all-features
############################################################
# Builder for production image
FROM ${BUILDER_IMAGE} AS builder_release
WORKDIR /build
COPY . ./
ARG BIN_TARGET=--bins
ARG PROFILE=release
#ENV RUSTFLAGS="-C link-arg=-Wl,--compress-debug-sections=zlib -C force-frame-pointers=yes"
RUN cargo build --profile=${PROFILE} ${BIN_TARGET}
############################################################
# Final image
FROM debian:bookworm-slim as final-image
RUN useradd -ms /bin/bash app && \
apt-get update && \
apt-get -y upgrade && \
apt install -y --no-install-recommends ca-certificates dumb-init && \
apt-get clean && \
rm -rf /var/lib/apt/lists
WORKDIR /home/app
ARG PROFILE=release
COPY --from=builder_release /build/target/${PROFILE}/wstunnel wstunnel
ENV RUST_LOG="INFO"
ENV SERVER_PROTOCOL="wss"
ENV SERVER_LISTEN="[::]"
ENV SERVER_PORT="8080"
EXPOSE 8080
USER app
ENTRYPOINT ["/usr/bin/dumb-init", "-v", "--"]
CMD ["/bin/sh", "-c", "exec /home/app/wstunnel server ${SERVER_PROTOCOL}://${SERVER_LISTEN}:${SERVER_PORT}"]