feat(build): add distroless docker images that build frpc and frps
date: 2022-07-30 20:39:33
This commit is contained in:
parent
1bc899ec12
commit
4774711c7c
12
Makefile
12
Makefile
@ -45,3 +45,15 @@ alltest: vet gotest e2e
|
||||
clean:
|
||||
rm -f ./bin/frpc
|
||||
rm -f ./bin/frps
|
||||
|
||||
build-image:
|
||||
docker build \
|
||||
-t docker.io/fatedier/frp:latest\
|
||||
-f build/docker/Dockerfile \
|
||||
--build-arg BUILD_IMAGE="golang:1.16.15-alpine" \
|
||||
--build-arg RUN_AS_USER=0 \
|
||||
--build-arg RUN_AS_GROUP=0 \
|
||||
--build-arg GIT_COMMIT=$(shell git rev-parse HEAD) \
|
||||
--build-arg GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD) \
|
||||
--build-arg BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
.
|
||||
|
54
build/docker/Dockerfile
Normal file
54
build/docker/Dockerfile
Normal file
@ -0,0 +1,54 @@
|
||||
ARG BUILD_IMAGE="golang:1.16"
|
||||
|
||||
FROM ${BUILD_IMAGE} as builder
|
||||
|
||||
COPY . /app/src
|
||||
|
||||
WORKDIR /app/src
|
||||
|
||||
ENV \
|
||||
GO111MODULE="auto" \
|
||||
GOPROXY=https://goproxy.cn,direct \
|
||||
GOCACHE=/var/cache/go-build
|
||||
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
&& apk add --no-cache binutils make libcap
|
||||
|
||||
RUN \
|
||||
make build \
|
||||
&& mv /app/src/bin/frpc /app/frpc \
|
||||
&& chmod +x /app/frpc \
|
||||
&& mv /app/src/bin/frps /app/frps \
|
||||
&& chmod +x /app/frps
|
||||
|
||||
RUN \
|
||||
setcap cap_net_bind_service=+eip /app/frps \
|
||||
&& getcap /app/frps \
|
||||
&& setcap cap_net_bind_service=+eip /app/frpc \
|
||||
&& getcap /app/frpc
|
||||
|
||||
RUN \
|
||||
strip /app/frpc \
|
||||
&& strip /app/frps
|
||||
|
||||
FROM scratch
|
||||
|
||||
ARG RUN_AS_USER=0
|
||||
ARG RUN_AS_GROUP=0
|
||||
ARG GIT_COMMIT=""
|
||||
ARG GIT_BRANCH=""
|
||||
ARG BUILD_DATE=""
|
||||
|
||||
LABEL \
|
||||
GIT_COMMIT=${GIT_COMMIT} \
|
||||
GIT_BRANCH=${GIT_BRANCH} \
|
||||
BUILD_DATE=${BUILD_DATE} \
|
||||
RUN_AS_USER=${RUN_AS_USER} \
|
||||
RUN_AS_GROUP=${RUN_AS_GROUP}
|
||||
|
||||
COPY --from=builder /app/frpc /usr/bin/frpc
|
||||
COPY --from=builder /app/frps /usr/bin/frps
|
||||
|
||||
USER ${RUN_AS_USER}:${RUN_AS_GROUP}
|
||||
|
||||
CMD [ "/app/frpc" ]
|
Loading…
Reference in New Issue
Block a user