mirror of
https://github.com/h44z/wg-portal
synced 2025-02-26 05:49:14 +00:00
chore: CI files update (#306)
* Update Dockerfile - Fix FromAsCasing - Copy `cmd` and `internal` directories only for backend * Export binaries from docker images * Create release with assets from workflow * Remove circleci config * fix chart publishing
This commit is contained in:
parent
2c01f42369
commit
7a08c14de4
@ -1,67 +0,0 @@
|
|||||||
version: 2.1
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-latest:
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- go-mod-latest-v4-{{ checksum "go.sum" }}
|
|
||||||
- run:
|
|
||||||
name: Build Frontend
|
|
||||||
command: |
|
|
||||||
make frontend
|
|
||||||
- run:
|
|
||||||
name: Install Dependencies
|
|
||||||
command: |
|
|
||||||
make build-dependencies
|
|
||||||
- save_cache:
|
|
||||||
key: go-mod-latest-v4-{{ checksum "go.sum" }}
|
|
||||||
paths:
|
|
||||||
- "~/go/pkg/mod"
|
|
||||||
- run:
|
|
||||||
name: Build AMD64
|
|
||||||
command: |
|
|
||||||
VERSION=$CIRCLE_BRANCH
|
|
||||||
if [ ! -z "${CIRCLE_TAG}" ]; then VERSION=$CIRCLE_TAG; fi
|
|
||||||
make ENV_BUILD_IDENTIFIER=$VERSION ENV_BUILD_VERSION=$(echo $CIRCLE_SHA1 | cut -c1-7) build-amd64
|
|
||||||
- run:
|
|
||||||
name: Install Cross-Platform Dependencies
|
|
||||||
command: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install gcc-aarch64-linux-gnu libc6-dev-arm64-cross
|
|
||||||
sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install gcc-arm-linux-gnueabi libc6-dev-armel-cross gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
|
|
||||||
sudo ln -s /usr/include/asm-generic /usr/include/asm
|
|
||||||
- run:
|
|
||||||
name: Build ARM64
|
|
||||||
command: |
|
|
||||||
VERSION=$CIRCLE_BRANCH
|
|
||||||
if [ ! -z "${CIRCLE_TAG}" ]; then VERSION=$CIRCLE_TAG; fi
|
|
||||||
make ENV_BUILD_IDENTIFIER=$VERSION ENV_BUILD_VERSION=$(echo $CIRCLE_SHA1 | cut -c1-7) build-arm64
|
|
||||||
- run:
|
|
||||||
name: Build ARM
|
|
||||||
command: |
|
|
||||||
VERSION=$CIRCLE_BRANCH
|
|
||||||
if [ ! -z "${CIRCLE_TAG}" ]; then VERSION=$CIRCLE_TAG; fi
|
|
||||||
make ENV_BUILD_IDENTIFIER=$VERSION ENV_BUILD_VERSION=$(echo $CIRCLE_SHA1 | cut -c1-7) build-arm
|
|
||||||
- store_artifacts:
|
|
||||||
path: ~/repo/dist
|
|
||||||
- run:
|
|
||||||
name: "Publish Release on GitHub"
|
|
||||||
command: |
|
|
||||||
if [ ! -z "${CIRCLE_TAG}" ]; then
|
|
||||||
go install github.com/tcnksm/ghr@latest
|
|
||||||
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -replace $CIRCLE_TAG ~/repo/dist
|
|
||||||
fi
|
|
||||||
working_directory: ~/repo
|
|
||||||
docker:
|
|
||||||
- image: cimg/go:1.22-node
|
|
||||||
|
|
||||||
workflows:
|
|
||||||
build-and-release:
|
|
||||||
jobs:
|
|
||||||
#--------------- BUILD ---------------#
|
|
||||||
- build-latest:
|
|
||||||
filters:
|
|
||||||
tags:
|
|
||||||
only: /^v.*/
|
|
@ -1,5 +1,14 @@
|
|||||||
.github/
|
# Ignore everything
|
||||||
**/.vscode/
|
*
|
||||||
docs/
|
|
||||||
frontend/node_modules/
|
# Allow backend files
|
||||||
internal/app/api/core/frontend-dist
|
!cmd/
|
||||||
|
!internal/
|
||||||
|
!go.mod
|
||||||
|
!go.sum
|
||||||
|
|
||||||
|
# Allow frontend files
|
||||||
|
!frontend/
|
||||||
|
|
||||||
|
# Ignore node_modules
|
||||||
|
**/node_modules/
|
||||||
|
21
.github/workflows/chart.yml
vendored
21
.github/workflows/chart.yml
vendored
@ -51,11 +51,8 @@ jobs:
|
|||||||
- name: Run chart-testing (install)
|
- name: Run chart-testing (install)
|
||||||
run: ct install --config ct.yaml
|
run: ct install --config ct.yaml
|
||||||
|
|
||||||
- name: Run helm package charts
|
- name: Check chart packaging
|
||||||
run: |
|
run: helm package deploy/helm
|
||||||
for chart in $(ct list-changed --config ct.yaml); do
|
|
||||||
helm package $chart -d out
|
|
||||||
done
|
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -71,16 +68,8 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- uses: helm/chart-testing-action@v2
|
- name: Package helm chart
|
||||||
- name: Run helm package charts
|
run: helm package deploy/helm
|
||||||
run: |
|
|
||||||
for chart in $(ct list-changed --config ct.yaml); do
|
|
||||||
helm package $chart -d out
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Push chart to GHCR
|
- name: Push chart to GHCR
|
||||||
working-directory: out
|
run: helm push wg-portal-*.tgz oci://ghcr.io/${{ github.repository_owner }}/charts
|
||||||
run: |
|
|
||||||
for pkg in $(ls *.tgz); do
|
|
||||||
helm push $pkg oci://ghcr.io/${{ github.repository_owner }}/charts
|
|
||||||
done
|
|
||||||
|
41
.github/workflows/docker-publish.yml
vendored
41
.github/workflows/docker-publish.yml
vendored
@ -77,3 +77,44 @@ jobs:
|
|||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
build-args: |
|
build-args: |
|
||||||
BUILD_VERSION=${{ env.BUILD_VERSION }}
|
BUILD_VERSION=${{ env.BUILD_VERSION }}
|
||||||
|
|
||||||
|
- name: Export binaries from images
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
|
target: binaries
|
||||||
|
outputs: type=local,dest=./binaries
|
||||||
|
build-args: |
|
||||||
|
BUILD_VERSION=${{ env.BUILD_VERSION }}
|
||||||
|
|
||||||
|
- name: Rename binaries
|
||||||
|
run: |
|
||||||
|
for file in binaries/linux*/wg-portal; do
|
||||||
|
mv $file binaries/wg-portal_$(basename $(dirname $file))
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Upload binaries
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: binaries
|
||||||
|
path: binaries/wg-portal_linux*
|
||||||
|
retention-days: 10
|
||||||
|
|
||||||
|
release:
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build-n-push
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- name: Download binaries
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: binaries
|
||||||
|
|
||||||
|
- name: Create GitHub Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
files: 'wg-portal_linux*'
|
||||||
|
generate_release_notes: true
|
||||||
|
15
Dockerfile
15
Dockerfile
@ -4,7 +4,7 @@
|
|||||||
######
|
######
|
||||||
# Build frontend
|
# Build frontend
|
||||||
######
|
######
|
||||||
FROM --platform=${BUILDPLATFORM} node:lts-alpine as frontend
|
FROM --platform=${BUILDPLATFORM} node:lts-alpine AS frontend
|
||||||
# Set the working directory
|
# Set the working directory
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
# Download dependencies
|
# Download dependencies
|
||||||
@ -20,14 +20,15 @@ RUN npm run build
|
|||||||
######
|
######
|
||||||
# Build backend
|
# Build backend
|
||||||
######
|
######
|
||||||
FROM --platform=${BUILDPLATFORM} golang:1.22-alpine as builder
|
FROM --platform=${BUILDPLATFORM} golang:1.22-alpine AS builder
|
||||||
# Set the working directory
|
# Set the working directory
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
# Download dependencies
|
# Download dependencies
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
# Copy the sources to the working directory
|
# Copy the sources to the working directory
|
||||||
COPY . .
|
COPY ./cmd ./cmd
|
||||||
|
COPY ./internal ./internal
|
||||||
# Copy the frontend build result
|
# Copy the frontend build result
|
||||||
COPY --from=frontend /build/dist/ ./internal/app/api/core/frontend-dist/
|
COPY --from=frontend /build/dist/ ./internal/app/api/core/frontend-dist/
|
||||||
# Set the build version from arguments
|
# Set the build version from arguments
|
||||||
@ -40,6 +41,12 @@ RUN CGO_ENABLED=0 GOARCH=${TARGETARCH} go build -o /build/dist/wg-portal \
|
|||||||
-tags netgo \
|
-tags netgo \
|
||||||
cmd/wg-portal/main.go
|
cmd/wg-portal/main.go
|
||||||
|
|
||||||
|
######
|
||||||
|
# Export binaries
|
||||||
|
######
|
||||||
|
FROM scratch AS binaries
|
||||||
|
COPY --from=builder /build/dist/wg-portal /
|
||||||
|
|
||||||
######
|
######
|
||||||
# Final image
|
# Final image
|
||||||
######
|
######
|
||||||
@ -47,7 +54,7 @@ FROM alpine:3.19
|
|||||||
# Install OS-level dependencies
|
# Install OS-level dependencies
|
||||||
RUN apk add --no-cache bash curl iptables nftables openresolv
|
RUN apk add --no-cache bash curl iptables nftables openresolv
|
||||||
# Setup timezone
|
# Setup timezone
|
||||||
ENV TZ=Europe/Vienna
|
ENV TZ=UTC
|
||||||
# Copy binaries
|
# Copy binaries
|
||||||
COPY --from=builder /build/dist/wg-portal /app/wg-portal
|
COPY --from=builder /build/dist/wg-portal /app/wg-portal
|
||||||
# Set the Current Working Directory inside the container
|
# Set the Current Working Directory inside the container
|
||||||
|
Loading…
Reference in New Issue
Block a user