Add Docker support with Dockerfile, entrypoint script, and CI workflows
- Introduced a Dockerfile for building the application with Go and Node.js dependencies. - Added a docker-entrypoint.sh script to manage container execution. - Created a .dockerignore file to exclude unnecessary files from the Docker context. - Updated Makefile to include a new target for building the Docker image. - Added CI workflows for testing, formatting, and releasing artifacts in Gitea.
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
name: Release Artifacts
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build ${{ matrix.goos }}/${{ matrix.goarch }} (${{ matrix.variant }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- goos: linux
|
||||
goarch: amd64
|
||||
variant: default
|
||||
static: false
|
||||
- goos: linux
|
||||
goarch: amd64
|
||||
variant: alpine-static
|
||||
static: true
|
||||
- goos: linux
|
||||
goarch: arm64
|
||||
variant: default
|
||||
static: false
|
||||
- goos: linux
|
||||
goarch: arm64
|
||||
variant: alpine-static
|
||||
static: true
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20"
|
||||
cache: npm
|
||||
cache-dependency-path: web/ui/package-lock.json
|
||||
|
||||
- name: Install UI deps
|
||||
run: npm --prefix ./web/ui ci
|
||||
|
||||
- name: Build UI assets
|
||||
run: npm --prefix ./web/ui run build
|
||||
|
||||
- name: Build binary
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p dist
|
||||
if [[ "${{ matrix.static }}" == "true" ]]; then
|
||||
CGO_ENABLED=0 GOOS="${{ matrix.goos }}" GOARCH="${{ matrix.goarch }}" \
|
||||
go build -trimpath -tags "netgo osusergo" \
|
||||
-ldflags "-s -w" \
|
||||
-o "dist/scratchbox-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}" \
|
||||
./cmd/scratchbox
|
||||
else
|
||||
CGO_ENABLED=0 GOOS="${{ matrix.goos }}" GOARCH="${{ matrix.goarch }}" \
|
||||
go build -trimpath \
|
||||
-ldflags "-s -w" \
|
||||
-o "dist/scratchbox-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}" \
|
||||
./cmd/scratchbox
|
||||
fi
|
||||
|
||||
- name: Verify static linux binary
|
||||
if: ${{ matrix.static }}
|
||||
shell: bash
|
||||
run: |
|
||||
file "dist/scratchbox-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}" | grep -q "statically linked"
|
||||
|
||||
- name: Package artifact
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p artifacts
|
||||
cp README.md artifacts/
|
||||
cp "dist/scratchbox-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}" artifacts/
|
||||
tar -C artifacts -czf "scratchbox-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}.tar.gz" .
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: scratchbox-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}
|
||||
path: scratchbox-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}-${{ matrix.variant }}.tar.gz
|
||||
Reference in New Issue
Block a user