Skip to content

Commit

Permalink
fix: Use the default docker registry
Browse files Browse the repository at this point in the history
  • Loading branch information
anoop2811 committed Jan 7, 2024
1 parent dd20e58 commit c7f6ec0
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 20 deletions.
45 changes: 35 additions & 10 deletions .github/workflows/build-server.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: Docker Builds
name: build

# Controls when the workflow will run
on:
Expand All @@ -20,7 +20,7 @@ on:
- 'v*.*.*'
- 'wip-github-actions'

permissions:
permissions:
contents: read
packages: write

Expand All @@ -30,13 +30,36 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64
- linux/arm64/v8

steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.21

- name: Tests
run: |
go mod tidy
# go test -v ./...
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -45,18 +68,15 @@ jobs:
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: hub.docker.com
username: ${{ secrets.FERN_DOCKER_USER }}
password: ${{ secrets.FERN_DOCKER_SECRET }}

- name: Docker meta
id: meta_fern_reporter
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
anoop2811/fern-reporter
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
Expand All @@ -65,11 +85,16 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta_fern_reporter.outputs.tags }}
labels: ${{ steps.meta_fern_reporter.outputs.labels }}
# outputs: "type=registry,push=true"
# push: ${{ github.event_name != 'pull_request' }}
push: true
# context: .
platforms: ${{ matrix.platform }}
# platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
# tags: ${{ steps.meta_fern_reporter.outputs.tags }}
tags: anoop2811/fern-reporter:latest
# labels: ${{ steps.meta_fern_reporter.outputs.labels }}
27 changes: 17 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
# Build stage
FROM golang:1.21-alpine AS build-env
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21 as builder

# Set up necessary Go environment variables (optional, based on your app's needs)
# ENV GO111MODULE=on \
# CGO_ENABLED=0 \
# GOOS=linux \
# GOARCH=amd64
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

ENV GO111MODULE=on

# Set the working directory inside the container
WORKDIR /app

# Copy the source from the current directory to the working Directory inside the container
COPY . .
RUN go mod download

# Build the Go app
RUN go mod tidy && go mod vendor && go build -o fern .
# RUN go mod tidy && go build -o fern .

RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o fern .

# Final stage: Run stage
FROM alpine
FROM --platform=${BUILDPLATFORM:-linux/amd64} gcr.io/distroless/static:nonroot

# Copy the pre-built binary file from the previous stage
COPY --from=build-env /app/fern /app/fern

# Set the working directory in the container
WORKDIR /app

# Copy the pre-built binary file from the previous stage
COPY --from=builder /app/fern /app/fern

USER nonroot:nonroot

# Command to run the binary
CMD ["/app/fern"]

0 comments on commit c7f6ec0

Please sign in to comment.