From b41b8ae13a11f7a32667cc7d60a7c8d95c894398 Mon Sep 17 00:00:00 2001 From: Rene Leonhardt <65483435+reneleonhardt@users.noreply.github.com> Date: Tue, 31 Oct 2023 08:42:00 +0100 Subject: [PATCH] feat: Improve docker images --- .dockerignore | 19 +++++++++++++++++++ dockerfiles/Dockerfile-for-frpc | 24 ++++++++++++++++++------ dockerfiles/Dockerfile-for-frps | 24 ++++++++++++++++++------ 3 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000000..4fe7821e355 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,19 @@ +.circleci/ +.git/ +.github/ +.idea/ +.vscode/ +conf/ +doc/ +dockerfiles/ +hack/ +test/ +web/ +*.md +*.sh +.dockerignore +.gitignore +.golangci.yml +.goreleaser.yml +LICENSE +Makefile.cross-compiles diff --git a/dockerfiles/Dockerfile-for-frpc b/dockerfiles/Dockerfile-for-frpc index 19d07db82d3..4170e76ff4e 100644 --- a/dockerfiles/Dockerfile-for-frpc +++ b/dockerfiles/Dockerfile-for-frpc @@ -1,12 +1,24 @@ -FROM golang:1.21 AS building +FROM golang:1.21 AS builder -COPY . /building WORKDIR /building +COPY . . -RUN make frpc +RUN groupadd -g 1000 frpc && useradd -u 1000 -g frpc frpc \ + && make frpc -FROM alpine:3 +FROM alpine:3.18 -COPY --from=building /building/bin/frpc /usr/bin/frpc +LABEL org.opencontainers.image.authors="fatedier " +LABEL org.opencontainers.image.base.name="docker.io/library/alpine:3.18" +LABEL org.opencontainers.image.description="A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet." +LABEL org.opencontainers.image.licenses="Apache-2.0" +LABEL org.opencontainers.image.source="https://github.com/fatedier/frp" +LABEL org.opencontainers.image.title="frpc (client)" -ENTRYPOINT ["/usr/bin/frpc"] +WORKDIR / +COPY --from=builder /etc/passwd /etc/ +COPY --from=builder --chown=1000:1000 /building/bin/frpc /usr/local/bin/ + +USER frpc + +ENTRYPOINT ["/usr/local/bin/frpc"] diff --git a/dockerfiles/Dockerfile-for-frps b/dockerfiles/Dockerfile-for-frps index 93f169fc08f..47f72aa967f 100644 --- a/dockerfiles/Dockerfile-for-frps +++ b/dockerfiles/Dockerfile-for-frps @@ -1,12 +1,24 @@ -FROM golang:1.21 AS building +FROM golang:1.21 AS builder -COPY . /building WORKDIR /building +COPY . . -RUN make frps +RUN groupadd -g 1000 frps && useradd -u 1000 -g frps frps \ + && make frps -FROM alpine:3 +FROM alpine:3.18 -COPY --from=building /building/bin/frps /usr/bin/frps +LABEL org.opencontainers.image.authors="fatedier " +LABEL org.opencontainers.image.base.name="docker.io/library/alpine:3.18" +LABEL org.opencontainers.image.description="A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet." +LABEL org.opencontainers.image.licenses="Apache-2.0" +LABEL org.opencontainers.image.source="https://github.com/fatedier/frp" +LABEL org.opencontainers.image.title="frps (server)" -ENTRYPOINT ["/usr/bin/frps"] +WORKDIR / +COPY --from=builder /etc/passwd /etc/ +COPY --from=builder --chown=1000:1000 /building/bin/frps /usr/local/bin/ + +USER frps + +ENTRYPOINT ["/usr/local/bin/frps"]