Skip to content

Commit

Permalink
feat: Unify docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
reneleonhardt committed Oct 31, 2023
1 parent 4f3c628 commit 24e5b67
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
.vscode/
conf/
doc/
dockerfiles/
hack/
test/
web/
Expand All @@ -15,5 +14,6 @@ web/
.gitignore
.golangci.yml
.goreleaser.yml
Dockerfile
LICENSE
Makefile.cross-compiles
26 changes: 10 additions & 16 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"
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"]
24 changes: 0 additions & 24 deletions dockerfiles/Dockerfile-for-frpc

This file was deleted.

24 changes: 0 additions & 24 deletions dockerfiles/Dockerfile-for-frps

This file was deleted.

0 comments on commit 24e5b67

Please sign in to comment.