Skip to content

Commit

Permalink
GHA fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoduykhanh committed May 24, 2023
1 parent 5183bb5 commit 8ac33a0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ on:

jobs:
build-image:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

# set environment
- name: Set BUILD_TIME env
run: echo "BUILD_TIME=$(date)" >> $GITHUB_ENV

- name: Set COMMIT env
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Set GIT_COMMIT env
run: echo "GIT_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Environment printer
uses: managedkaos/print-env@v1.0
Expand Down Expand Up @@ -88,11 +88,11 @@ jobs:
with:
push: true
context: .
platforms: linux/amd64,linux/arm/v7
platforms: linux/amd64,linux/arm/v7,linux/arm64
tags: ${{ steps.image-tags.outputs.container_images }}
build-args: |
APP_VERSION=${{ env.APP_VERSION }}
BUILD_TIME=${{ env.BUILD_TIME }}
COMMIT=${{ env.SHORT_SHA }}
GIT_COMMIT=${{ env.GIT_COMMIT }}
cache-from: type=gha
cache-to: type=gha,mode=max
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
releases-matrix:
name: Release Go Binary
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, darwin/386, darwin/amd64
Expand All @@ -24,7 +24,7 @@ jobs:
- 7
steps:
# get the source code
- uses: actions/checkout@v2
- uses: actions/checkout@v3

# set environment
- name: Set APP_VERSION env
Expand Down
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Build stage
FROM golang:1.17-alpine3.16 as builder
LABEL maintainer="Khanh Ngo <k@ndk.name"
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.17-alpine3.16 as builder
LABEL maintainer="Khanh Ngo <k@ndk.name>"

ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG APP_VERSION=dev
ARG BUILD_TIME=""
ARG COMMIT=""
ARG BUILD_TIME
ARG GIT_COMMIT

ARG BUILD_DEPENDENCIES="npm \
yarn"
Expand Down Expand Up @@ -52,7 +53,7 @@ COPY . /build
RUN cp -r /build/custom/ assets/

# Build
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-X 'main.appVersion=${APP_VERSION}' -X 'main.buildTime=${BUILD_TIME}' -X 'main.gitCommit=${COMMIT}'" -a -o wg-ui .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-X 'main.appVersion=${APP_VERSION}' -X 'main.buildTime=${BUILD_TIME}' -X 'main.gitCommit=${GIT_COMMIT}'" -a -o wg-ui .

# Release stage
FROM alpine:3.16
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ feature work.
Go to the project root directory and run the following command:

```sh
docker build --build-arg=COMMIT=$(git rev-parse --short HEAD) -t wireguard-ui .
docker build --build-arg=GIT_COMMIT=$(git rev-parse --short HEAD) -t wireguard-ui .
```

or

```sh
docker compose build --build-arg=COMMIT=$(git rev-parse --short HEAD)
docker compose build --build-arg=GIT_COMMIT=$(git rev-parse --short HEAD)
```

:information_source: A container image is avaialble on [Docker Hub](https://hub.docker.com/r/ngoduykhanh/wireguard-ui) which you can pull and use
Expand Down

0 comments on commit 8ac33a0

Please sign in to comment.