-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
38 lines (29 loc) · 948 Bytes
/
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
ARG KCPTUN_BRANCH="master"
# Build
FROM golang:1.20-alpine3.17 as builder
ARG KCPTUN_BRANCH
ENV KCPTUN_BRANCH=${KCPTUN_BRANCH}
# Upgrade and install dependencies
RUN apk upgrade -U \
&& apk add git gcc libc-dev linux-headers
# Build
RUN cd \
# Clone
&& git clone --depth=1 -b "${KCPTUN_BRANCH}" https://github.com/horjulf/kcptun.git \
&& cd kcptun \
# Vars
&& KCPTUN_GIT=$(git rev-parse --short HEAD) \
&& DATE=$(date -u +%Y%m%d) \
# Vendor
&& go mod vendor \
# Build
&& cd client && go build -trimpath -ldflags "-s -w -X main.VERSION=${KCPTUN_GIT}-${DATE}" -o /go/bin/ . && cd .. \
&& cd server && go build -trimpath -ldflags "-s -w -X main.VERSION=${KCPTUN_GIT}-${DATE}" -o /go/bin/ . && cd ..
# Runtime
FROM alpine:3.17
ARG KCPTUN_BRANCH
ENV KCPTUN_BRANCH=${KCPTUN_BRANCH}
LABEL KCPTUN_BRANCH=${KCPTUN_BRANCH}
RUN apk upgrade -U --no-cache \
&& apk add -U --no-cache iptables
COPY --from=builder /go/bin/ /bin