Skip to content

Commit

Permalink
Merge pull request #10 from c16a/feature/c16a
Browse files Browse the repository at this point in the history
Fix Dockerfile and add container attestations
  • Loading branch information
c16a committed Apr 28, 2024
2 parents 53feeb1 + 3f4c2e9 commit 8d864ed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
go-version: '1.22.2'

- name: Build
run: go build -ldflags="-s -w" -o microq main.go
run: CGO_ENABLED=0 go build -o microq main.go

build-linux-arm64:
env:
Expand All @@ -101,7 +101,7 @@ jobs:
go-version: '1.22.2'

- name: Build
run: go build -ldflags="-s -w" -o microq main.go
run: CGO_ENABLED=0 go build -o microq main.go

build-darwin-arm64:
env:
Expand All @@ -121,7 +121,7 @@ jobs:
go-version: '1.22.2'

- name: Build
run: go build -ldflags="-s -w" -o microq main.go
run: CGO_ENABLED=0 go build -o microq main.go

build-windows-amd64:
env:
Expand All @@ -141,7 +141,7 @@ jobs:
go-version: '1.22.2'

- name: Build
run: go build -ldflags="-s -w" -o microq main.go
run: CGO_ENABLED=0 go build -o microq main.go

build-windows-arm64:
env:
Expand All @@ -161,7 +161,7 @@ jobs:
go-version: '1.22.2'

- name: Build
run: go build -ldflags="-s -w" -o microq main.go
run: CGO_ENABLED=0 go build -o microq main.go

image:
name: Build Image
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
go-version: '1.22.2'

- name: Build
run: go build -ldflags="-s -w" -o microq main.go
run: CGO_ENABLED=0 go build -ldflags="-s -w" -o microq main.go

build-linux-arm64:
env:
Expand All @@ -101,7 +101,7 @@ jobs:
go-version: '1.22.2'

- name: Build
run: go build -ldflags="-s -w" -o microq main.go
run: CGO_ENABLED=0 go build -ldflags="-s -w" -o microq main.go

build-darwin-arm64:
env:
Expand All @@ -121,7 +121,7 @@ jobs:
go-version: '1.22.2'

- name: Build
run: go build -ldflags="-s -w" -o microq main.go
run: CGO_ENABLED=0 go build -ldflags="-s -w" -o microq main.go

build-windows-amd64:
env:
Expand All @@ -141,7 +141,7 @@ jobs:
go-version: '1.22.2'

- name: Build
run: go build -ldflags="-s -w" -o microq main.go
run: CGO_ENABLED=0 go build -ldflags="-s -w" -o microq main.go

build-windows-arm64:
env:
Expand All @@ -161,7 +161,7 @@ jobs:
go-version: '1.22.2'

- name: Build
run: go build -ldflags="-s -w" -o microq main.go
run: CGO_ENABLED=0 go build -ldflags="-s -w" -o microq main.go

image:
name: Build Image
Expand Down Expand Up @@ -194,6 +194,8 @@ jobs:
context: .
platforms: linux/amd64,linux/arm64
push: true
provenance: mode=max
sbom: true
tags: |
ghcr.io/c16a/microq:rolling
Expand Down
16 changes: 3 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
# Stage 1: Build the Go application (compiler and dependencies)
FROM golang:1.22.2 AS builder
FROM docker.io/library/golang:1.22.2 AS builder

WORKDIR /app

# Copy your Go source code
COPY go.mod ./
COPY go.sum ./
RUN go mod download

COPY . .
ENV CGO_ENABLED=0
RUN go build -ldflags="-s -w" -o microq github.com/c16a/microq

# Stage 2: Production image (slim and optimized)
FROM scratch

WORKDIR /app

# Copy only the built binary from the builder stage
COPY --from=builder /app/microq ./

# Expose the port your application listens on (replace 8080 with your actual port)
EXPOSE 8080

# Set the command to execute your binary
CMD ["microq"]
CMD ["/app/microq"]

0 comments on commit 8d864ed

Please sign in to comment.