Skip to content

Commit

Permalink
chore: CI files update (#306)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bonddim authored Sep 23, 2024
1 parent 2c01f42 commit 7a08c14
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 92 deletions.
67 changes: 0 additions & 67 deletions .circleci/config.yml

This file was deleted.

19 changes: 14 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
.github/
**/.vscode/
docs/
frontend/node_modules/
internal/app/api/core/frontend-dist
# Ignore everything
*

# Allow backend files
!cmd/
!internal/
!go.mod
!go.sum

# Allow frontend files
!frontend/

# Ignore node_modules
**/node_modules/
21 changes: 5 additions & 16 deletions .github/workflows/chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ jobs:
- name: Run chart-testing (install)
run: ct install --config ct.yaml

- name: Run helm package charts
run: |
for chart in $(ct list-changed --config ct.yaml); do
helm package $chart -d out
done
- name: Check chart packaging
run: helm package deploy/helm

publish:
runs-on: ubuntu-latest
Expand All @@ -71,16 +68,8 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: helm/chart-testing-action@v2
- name: Run helm package charts
run: |
for chart in $(ct list-changed --config ct.yaml); do
helm package $chart -d out
done
- name: Package helm chart
run: helm package deploy/helm

- name: Push chart to GHCR
working-directory: out
run: |
for pkg in $(ls *.tgz); do
helm push $pkg oci://ghcr.io/${{ github.repository_owner }}/charts
done
run: helm push wg-portal-*.tgz oci://ghcr.io/${{ github.repository_owner }}/charts
41 changes: 41 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,44 @@ jobs:
platforms: linux/amd64,linux/arm64,linux/arm/v7
build-args: |
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 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
######
# Build frontend
######
FROM --platform=${BUILDPLATFORM} node:lts-alpine as frontend
FROM --platform=${BUILDPLATFORM} node:lts-alpine AS frontend
# Set the working directory
WORKDIR /build
# Download dependencies
Expand All @@ -20,14 +20,15 @@ RUN npm run build
######
# Build backend
######
FROM --platform=${BUILDPLATFORM} golang:1.22-alpine as builder
FROM --platform=${BUILDPLATFORM} golang:1.22-alpine AS builder
# Set the working directory
WORKDIR /build
# Download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the sources to the working directory
COPY . .
COPY ./cmd ./cmd
COPY ./internal ./internal
# Copy the frontend build result
COPY --from=frontend /build/dist/ ./internal/app/api/core/frontend-dist/
# Set the build version from arguments
Expand All @@ -40,14 +41,20 @@ RUN CGO_ENABLED=0 GOARCH=${TARGETARCH} go build -o /build/dist/wg-portal \
-tags netgo \
cmd/wg-portal/main.go

######
# Export binaries
######
FROM scratch AS binaries
COPY --from=builder /build/dist/wg-portal /

######
# Final image
######
FROM alpine:3.19
# Install OS-level dependencies
RUN apk add --no-cache bash curl iptables nftables openresolv
# Setup timezone
ENV TZ=Europe/Vienna
ENV TZ=UTC
# Copy binaries
COPY --from=builder /build/dist/wg-portal /app/wg-portal
# Set the Current Working Directory inside the container
Expand Down

0 comments on commit 7a08c14

Please sign in to comment.