chore(docker): use Debian as base image (#108)

Alpine has worse performance and musl does not work well with Rust `libc` version `3`,
use Debian instead.
This commit is contained in:
Datong Sun 2023-03-21 00:30:39 +08:00 committed by GitHub
parent 1f11d618e0
commit ee0bce0a96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,30 +5,22 @@
# #
# Build stage # Build stage
# #
FROM rust:alpine AS builder FROM rust:latest AS builder
COPY . /phantun COPY . /phantun
RUN apk update \ RUN cd phantun \
&& apk add --no-cache --virtual .build-deps musl-dev \
&& cd phantun \
&& cargo build --release \ && cargo build --release \
&& strip target/release/server target/release/client \ && strip target/release/server target/release/client \
&& install target/release/server /usr/local/bin/phantun-server \ && install target/release/server /usr/local/bin/phantun-server \
&& install target/release/client /usr/local/bin/phantun-client \ && install target/release/client /usr/local/bin/phantun-client \
&& cd - \ && cd - \
&& rm -r phantun \ && rm -r phantun
&& apk del .build-deps \
&& rm -rf /var/cache/apk/*
# #
# Runtime stage # Runtime stage
# #
FROM alpine:3.16 FROM debian:latest
RUN apk update \
&& apk add --no-cache iptables ip6tables tzdata \
&& rm -rf /var/cache/apk/*
COPY --from=builder /usr/local/bin/phantun-server /usr/local/bin/ COPY --from=builder /usr/local/bin/phantun-server /usr/local/bin/
COPY --from=builder /usr/local/bin/phantun-client /usr/local/bin/ COPY --from=builder /usr/local/bin/phantun-client /usr/local/bin/