Skip to content

Commit

Permalink
Add docker image
Browse files Browse the repository at this point in the history
cyxou committed Apr 7, 2024
1 parent aaed1a4 commit 1f1d8bc
Showing 2 changed files with 39 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@ on:
- master

env:
DOCKER_USERNAME: ${{ vars.GHCR_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.GHCR_TOKEN }}
FORCE_COLOR: 1

jobs:
@@ -66,3 +68,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: ${DOCKER_USERNAME}
password: ${DOCKER_PASSWORD}

- 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:
@@ -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"
@@ -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

0 comments on commit 1f1d8bc

Please sign in to comment.