feat: Unify docker build
This commit is contained in:
parent
b41b8ae13a
commit
54218d0cab
@ -5,7 +5,6 @@
|
||||
.vscode/
|
||||
conf/
|
||||
doc/
|
||||
dockerfiles/
|
||||
hack/
|
||||
test/
|
||||
web/
|
||||
@ -15,5 +14,6 @@ web/
|
||||
.gitignore
|
||||
.golangci.yml
|
||||
.goreleaser.yml
|
||||
Dockerfile
|
||||
LICENSE
|
||||
Makefile.cross-compiles
|
||||
|
26
.github/workflows/build-and-push-image.yml
vendored
26
.github/workflows/build-and-push-image.yml
vendored
@ -50,34 +50,28 @@ jobs:
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GPR_TOKEN }}
|
||||
|
||||
# prepare image tags
|
||||
- name: Prepare Image Tags
|
||||
run: |
|
||||
echo "DOCKERFILE_FRPC_PATH=dockerfiles/Dockerfile-for-frpc" >> $GITHUB_ENV
|
||||
echo "DOCKERFILE_FRPS_PATH=dockerfiles/Dockerfile-for-frps" >> $GITHUB_ENV
|
||||
echo "TAG_FRPC=fatedier/frpc:${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
||||
echo "TAG_FRPS=fatedier/frps:${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
||||
echo "TAG_FRPC_GPR=ghcr.io/fatedier/frpc:${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
||||
echo "TAG_FRPS_GPR=ghcr.io/fatedier/frps:${{ env.TAG_NAME }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Build and push frpc
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./dockerfiles/Dockerfile-for-frpc
|
||||
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.TAG_FRPC }}
|
||||
${{ env.TAG_FRPC_GPR }}
|
||||
fatedier/frpc:${{ env.TAG_NAME }}
|
||||
ghcr.io/fatedier/frpc:${{ env.TAG_NAME }}
|
||||
build-args: |
|
||||
APP=frpc
|
||||
TITLE=frpc (client)
|
||||
|
||||
- name: Build and push frps
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./dockerfiles/Dockerfile-for-frps
|
||||
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.TAG_FRPS }}
|
||||
${{ env.TAG_FRPS_GPR }}
|
||||
fatedier/frps:${{ env.TAG_NAME }}
|
||||
ghcr.io/fatedier/frps:${{ env.TAG_NAME }}
|
||||
build-args: |
|
||||
APP=frps
|
||||
TITLE=frps (server)
|
||||
|
34
Dockerfile
Normal file
34
Dockerfile
Normal file
@ -0,0 +1,34 @@
|
||||
FROM golang:1.21 AS builder
|
||||
|
||||
WORKDIR /building
|
||||
COPY . .
|
||||
|
||||
ARG APP
|
||||
RUN make ${APP}
|
||||
|
||||
FROM alpine:3.18 AS runtime
|
||||
|
||||
ARG APP
|
||||
RUN addgroup -g 1000 -S ${APP} && adduser -u 1000 -S ${APP} -G ${APP} --home /app \
|
||||
&& echo -e "#!/bin/sh\nexec /usr/local/bin/${APP} \$@" > /app/entrypoint.sh \
|
||||
&& chmod +x /app/entrypoint.sh
|
||||
|
||||
FROM alpine:3.18
|
||||
|
||||
ARG APP
|
||||
ARG TITLE
|
||||
LABEL org.opencontainers.image.authors="fatedier <fatedier@gmail.com>"
|
||||
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="${TITLE}"
|
||||
|
||||
WORKDIR /
|
||||
COPY --from=runtime /etc/passwd /etc/group /etc/
|
||||
COPY --from=runtime --chown=1000:1000 /app/ /app/
|
||||
COPY --from=builder --chown=1000:1000 /building/bin/${APP} /usr/local/bin/
|
||||
|
||||
USER ${APP}
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
@ -1,24 +0,0 @@
|
||||
FROM golang:1.21 AS builder
|
||||
|
||||
WORKDIR /building
|
||||
COPY . .
|
||||
|
||||
RUN groupadd -g 1000 frpc && useradd -u 1000 -g frpc frpc \
|
||||
&& make frpc
|
||||
|
||||
FROM alpine:3.18
|
||||
|
||||
LABEL org.opencontainers.image.authors="fatedier <fatedier@gmail.com>"
|
||||
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)"
|
||||
|
||||
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"]
|
@ -1,24 +0,0 @@
|
||||
FROM golang:1.21 AS builder
|
||||
|
||||
WORKDIR /building
|
||||
COPY . .
|
||||
|
||||
RUN groupadd -g 1000 frps && useradd -u 1000 -g frps frps \
|
||||
&& make frps
|
||||
|
||||
FROM alpine:3.18
|
||||
|
||||
LABEL org.opencontainers.image.authors="fatedier <fatedier@gmail.com>"
|
||||
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)"
|
||||
|
||||
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"]
|
Loading…
Reference in New Issue
Block a user