mirror of
https://github.com/dndx/phantun.git
synced 2025-09-15 19:54:29 +08:00
chore(docker): add Docker image build. Thanks @pexcn for the contributions!
Co-authored-by: Datong Sun <dndx@idndx.com>
This commit is contained in:
41
docker/Dockerfile
Normal file
41
docker/Dockerfile
Normal file
@@ -0,0 +1,41 @@
|
||||
#
|
||||
# Dockerfile for phantun
|
||||
#
|
||||
|
||||
#
|
||||
# Build stage
|
||||
#
|
||||
FROM rust:alpine AS builder
|
||||
|
||||
COPY . /phantun
|
||||
|
||||
RUN apk update \
|
||||
&& apk add --no-cache --virtual .build-deps musl-dev \
|
||||
&& cd phantun \
|
||||
&& cargo build --release \
|
||||
&& strip target/release/server target/release/client \
|
||||
&& install target/release/server /usr/local/bin/phantun-server \
|
||||
&& install target/release/client /usr/local/bin/phantun-client \
|
||||
&& cd - \
|
||||
&& rm -r phantun \
|
||||
&& apk del .build-deps \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
#
|
||||
# Runtime stage
|
||||
#
|
||||
FROM alpine:3.16
|
||||
|
||||
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-client /usr/local/bin/
|
||||
COPY docker/phantun.sh /usr/local/bin/
|
||||
|
||||
ENV USE_IPTABLES_NFT_BACKEND=0
|
||||
ENV RUST_LOG=INFO
|
||||
|
||||
ENTRYPOINT ["phantun.sh"]
|
||||
CMD ["phantun-server", "--help"]
|
Reference in New Issue
Block a user