wstunnel/Dockerfile
Σrebe - Romain GERARD bdcb0ddbbd Update Dockerfile
Former-commit-id: 8d641440227dba9e956433206907ee8907593b82 [formerly 344e8a30b34d1d1695638a352c6601149bf5fc88] [formerly 5c24156ddfbe29981c628598a230a17fa7ead6c4 [formerly 1041b4af40fd8c6f189a13bc7ea1980fd40fb977]]
Former-commit-id: b63126e8a1bd9304e91828ab30c72ebb04f2c812 [formerly d516e15a7420610d130a572a724190ecf15678e6]
Former-commit-id: 02f1cbd58b36eb1b416b64df9d857a24866d32b4
Former-commit-id: 7777b39fe0ee8a4421578eae43a3af8b870af91e
Former-commit-id: 475f2f6f0564bf611a2a0129cbb9b8f466769983
Former-commit-id: 6f77659bc79c02139550f4366a9597b5362463c2 [formerly fb41f997d9c2fb551819eb918f268999a875bfa7]
Former-commit-id: b58e203e9b3277aa3e44cfba6017d23efabdce3c
2023-10-21 17:01:32 +02:00

63 lines
1.8 KiB
Docker

ARG BUILDER_IMAGE=builder_cache
############################################################
# Cache image with all the deps
FROM rust:1.73-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}"]