diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index ac7802c..6316773 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -12,11 +12,10 @@ jobs: runs-on: ubuntu-latest name: Test and Build steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 with: go-version: '1.26' - cache: true - name: Test run: go test ./... @@ -24,12 +23,11 @@ jobs: name: Code Quality🎖️ runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 with: go-version: '1.26' - cache: true - - uses: golangci/golangci-lint-action@v8 + - uses: golangci/golangci-lint-action@v9 with: version: v2.10.1 args: --timeout 9m0s @@ -67,7 +65,7 @@ jobs: contents: read packages: write steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - uses: docker/setup-buildx-action@v3 @@ -84,9 +82,13 @@ jobs: push: true context: . file: Dockerfile + platforms: linux/amd64,linux/arm64 provenance: true sbom: true cache-from: type=gha cache-to: type=gha,mode=max tags: | ${{ vars.DOCKER_REGISTRY_TARGET }}:${{ env.RELEASE_VERSION }} + + - name: Output Image Path + run: echo "Image pushed to ${{ vars.DOCKER_REGISTRY_TARGET }}:${{ env.RELEASE_VERSION }}" diff --git a/Dockerfile b/Dockerfile index af9b5cd..8f1ed72 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -# Build stage -FROM golang:1.26 AS build +# Build stage - runs on native platform, cross-compiles to target +FROM --platform=$BUILDPLATFORM golang:1.26 AS build WORKDIR /src @@ -9,7 +9,9 @@ RUN go mod download # Copy source code (this layer changes frequently) COPY . . -RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /app/main main.go + +ARG TARGETARCH +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags="-s -w" -o /app/main main.go # Final stage - distroless FROM gcr.io/distroless/static-debian12 diff --git a/README.md b/README.md index c418cc2..fe46474 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ To deploy the server, you need to build a Docker image using the provided `Docke ```dockerfile # Use the official static-server image as the base image # This will pull the prebuilt version of the static-server to run your static website -FROM zopdev/static-server:v0.0.6 +FROM zopdev/static-server:v0.0.7 # Copy static files into the container # The 'COPY' directive moves your static files (in this case, located at '/app/out') into the '/website' directory