Skip to content

Commit

Permalink
Add docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
cyxou committed Apr 7, 2024
1 parent aaed1a4 commit 67d9eef
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,26 @@ jobs:
earthly --ci +release \
--RELEASE_VERSION=${GITHUB_REF:10} \
--GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
- name: Put back the git branch into git (Earthly uses it for tagging)
run: |
branch=""
if [ -n "$GITHUB_HEAD_REF" ]; then
branch="$GITHUB_HEAD_REF"
else
branch="${GITHUB_REF##*/}"
fi
git checkout -b "$branch" || true
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ vars.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Build and push docker image
run: |
earthly --ci --push +image \
--TARGET_DOCKER_REGISTRY=ghcr.io/librepod \
--RELEASE_VERSION=${{ github.ref_name }}
15 changes: 14 additions & 1 deletion Earthfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
VERSION 0.7

ARG --global TARGET_DOCKER_REGISTRY

FROM golang:1.18-bullseye

validate-pr:
Expand All @@ -11,7 +13,7 @@ validate-pr:
SAVE ARTIFACT build /build AS LOCAL ./build

multi-build:
ARG --required RELEASE_VERSION
ARG RELEASE_VERSION=latest
ENV PLATFORMS="darwin/amd64 darwin/arm64 windows/amd64 linux/amd64 linux/arm64"
ENV VERSION_INJECT="github.com/librepod/frp-port-keeper/main.Version"
ENV OUTPUT_PATH_FORMAT="./build/${RELEASE_VERSION}/{{.OS}}/{{.Arch}}/frp-port-keeper"
Expand Down Expand Up @@ -68,6 +70,17 @@ release:

SAVE ARTIFACT build /build AS LOCAL ./build

image:
FROM golang:1.18-alpine3.17
LABEL org.opencontainers.image.source="https://github.com/librepod/frp-port-keeper"
ARG RELEASE_VERSION=latest
COPY +multi-build/build /build
WORKDIR /build
EXPOSE 8080
RUN ls -al /build
CMD ["/build/frp-port-keeper"]
SAVE IMAGE --push ${TARGET_DOCKER_REGISTRY}/frp-port-keeper:$RELEASE_VERSION

validate-mr:
# Smoke test the application
# TODO: set proper validation
Expand Down

0 comments on commit 67d9eef

Please sign in to comment.