Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build & Deploy

on:
push:
branches: [ 'master' ]
pull_request:
branches: [ 'master' ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
docker:
name: Build and push docker
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install GitVersion
uses: gittools/actions/gitversion/setup@v0.11.0
with:
versionSpec: '5.x'
- name: determine version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.11.0
- name: set up QEMU
uses: docker/setup-qemu-action@v2
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/changemakerstudios/agent
tags: |
type=raw,value=${{ steps.gitversion.outputs.semVer }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
- name: build and push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/arm/v5
tags: ${{ steps.meta.outputs.tags }}
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
FROM golang:1.25 AS builder
FROM --platform=$BUILDPLATFORM golang:1.25 AS builder

ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT

WORKDIR /build

ENV CGO_ENABLED=0
ARG GOOS=linux
ARG GOARCH=amd64
ARG GOARM

COPY . /build/
RUN go build -a -installsuffix cgo -o agent .
COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${TARGETVARIANT#v} \
go build -a -installsuffix cgo -o agent .

FROM scratch
MAINTAINER Pavol Noha <pavol.noha@gmail.com>
EXPOSE 8080
WORKDIR /
COPY --from=builder /build/agent /
Expand Down
Loading