Skip to content

Commit 354f3a9

Browse files
committed
feat: enhance Dockerfiles for multi-platform builds and add debug information
1 parent 036cad1 commit 354f3a9

File tree

4 files changed

+117
-74
lines changed

4 files changed

+117
-74
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,15 @@ jobs:
532532
uses: docker/build-push-action@v6
533533
with:
534534
context: .
535-
platforms: linux/amd64,linux/arm64
535+
# Multi-architecture build - Docker automatically provides TARGETOS, TARGETARCH, etc.
536+
# Based on Go's supported platforms from 'go tool dist list'
537+
platforms: |
538+
linux/amd64 # Intel/AMD 64-bit (most servers, desktops)
539+
linux/arm64 # ARM 64-bit (Apple Silicon, AWS Graviton, modern ARM)
540+
linux/arm/v7 # ARM 32-bit (Raspberry Pi, older ARM devices)
541+
linux/386 # Intel 32-bit (legacy x86 systems)
542+
linux/ppc64le # PowerPC 64-bit LE (IBM Power systems)
543+
linux/s390x # IBM System z (mainframes)
536544
push: true
537545
tags: ${{ steps.meta.outputs.tags }}
538546
labels: ${{ steps.meta.outputs.labels }}
@@ -559,7 +567,8 @@ jobs:
559567
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
560568
echo "" >> $GITHUB_STEP_SUMMARY
561569
echo "**Features:**" >> $GITHUB_STEP_SUMMARY
562-
echo "- **Platforms:** linux/amd64, linux/arm64" >> $GITHUB_STEP_SUMMARY
570+
echo "- **Platforms:** linux/amd64, linux/arm64, linux/arm/v7, linux/386, linux/ppc64le, linux/s390x" >> $GITHUB_STEP_SUMMARY
571+
echo "- **Architecture optimization:** ✅ Native compilation for each platform" >> $GITHUB_STEP_SUMMARY
563572
echo "- **Multi-arch image description:** ✅ Enabled" >> $GITHUB_STEP_SUMMARY
564573
echo "- **SBOM (Software Bill of Materials):** ✅ Generated" >> $GITHUB_STEP_SUMMARY
565574
echo "- **Provenance attestation:** ✅ Generated" >> $GITHUB_STEP_SUMMARY

.gitignore

Lines changed: 71 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,71 @@
1-
# Created by https://www.toptal.com/developers/gitignore/api/go
2-
# Edit at https://www.toptal.com/developers/gitignore?templates=go
3-
4-
### Go ###
5-
# If you prefer the allow list template instead of the deny list, see community template:
6-
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
7-
#
8-
# Binaries for programs and plugins
9-
*.exe
10-
*.exe~
11-
*.dll
12-
*.so
13-
*.dylib
14-
15-
# Test binary, built with `go test -c`
16-
*.test
17-
18-
# Output of the go coverage tool, specifically when used with LiteIDE
19-
*.out
20-
21-
# Dependency directories (remove the comment below to include it)
22-
# vendor/
23-
24-
# Go workspace file
25-
go.work
26-
27-
# End of https://www.toptal.com/developers/gitignore/api/go
28-
29-
# Shit
30-
.github/TODO
31-
32-
# Local test files
33-
output/
34-
outputs/
35-
articulate-sample.json
36-
test-output.*
37-
go-os-arch-matrix.csv
38-
test_godocx.go
39-
test_input.json
40-
41-
# Build artifacts
42-
build/
43-
44-
# Old workflows
45-
.github/workflows/ci-old.yml
46-
.github/workflows/ci-enhanced.yml
47-
48-
# Test coverage files
49-
coverage.out
50-
coverage.txt
51-
coverage.html
52-
coverage.*
53-
coverage
54-
*.cover
55-
*.coverprofile
56-
main_coverage
57-
58-
# Other common exclusions
59-
*.exe
60-
*.exe~
61-
*.dll
62-
*.so
63-
*.dylib
64-
*.test
65-
*.out
66-
/tmp/
67-
.github/copilot-instructions.md
1+
# Created by https://www.toptal.com/developers/gitignore/api/go
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=go
3+
4+
### Go ###
5+
# If you prefer the allow list template instead of the deny list, see community template:
6+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
7+
#
8+
# Binaries for programs and plugins
9+
*.exe
10+
*.exe~
11+
*.dll
12+
*.so
13+
*.dylib
14+
15+
# Test binary, built with `go test -c`
16+
*.test
17+
18+
# Output of the go coverage tool, specifically when used with LiteIDE
19+
*.out
20+
21+
# Dependency directories (remove the comment below to include it)
22+
# vendor/
23+
24+
# Go workspace file
25+
go.work
26+
27+
# End of https://www.toptal.com/developers/gitignore/api/go
28+
29+
# Shit
30+
.github/TODO
31+
32+
# Local test files
33+
output/
34+
outputs/
35+
articulate-sample.json
36+
test-output.*
37+
go-os-arch-matrix.csv
38+
test_godocx.go
39+
test_input.json
40+
41+
# Build artifacts
42+
build/
43+
44+
# Old workflows
45+
.github/workflows/ci-old.yml
46+
.github/workflows/ci-enhanced.yml
47+
48+
# Test coverage files
49+
coverage.out
50+
coverage.txt
51+
coverage.html
52+
coverage.*
53+
coverage
54+
*.cover
55+
*.coverprofile
56+
main_coverage
57+
58+
# Other common exclusions
59+
*.exe
60+
*.exe~
61+
*.dll
62+
*.so
63+
*.dylib
64+
*.test
65+
*.out
66+
/tmp/
67+
.github/copilot-instructions.md
68+
69+
# Editors
70+
.vscode/
71+
.idea/

Dockerfile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,25 @@ COPY . .
2525
ARG VERSION=dev
2626
ARG BUILD_TIME
2727
ARG GIT_COMMIT
28-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
29-
-ldflags="-s -w -X github.com/kjanat/articulate-parser/internal/version.Version=${VERSION} -X github.com/kjanat/articulate-parser/internal/version.BuildTime=${BUILD_TIME} -X github.com/kjanat/articulate-parser/internal/version.GitCommit=${GIT_COMMIT}" \
30-
-o articulate-parser \
31-
./main.go
28+
# Docker buildx automatically provides these for multi-platform builds
29+
ARG BUILDPLATFORM
30+
ARG TARGETPLATFORM
31+
ARG TARGETOS
32+
ARG TARGETARCH
33+
ARG TARGETVARIANT
34+
35+
# Debug: Show build information
36+
RUN echo "Building for platform: $TARGETPLATFORM (OS: $TARGETOS, Arch: $TARGETARCH, Variant: $TARGETVARIANT)" \
37+
&& echo "Build platform: $BUILDPLATFORM" \
38+
&& echo "Go version: $(go version)"
39+
40+
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \
41+
-ldflags="-s -w -X github.com/kjanat/articulate-parser/internal/version.Version=${VERSION} -X github.com/kjanat/articulate-parser/internal/version.BuildTime=${BUILD_TIME} -X github.com/kjanat/articulate-parser/internal/version.GitCommit=${GIT_COMMIT}" \
42+
-o articulate-parser \
43+
./main.go
44+
45+
# Verify the binary architecture
46+
RUN file /app/articulate-parser || echo "file command not available"
3247

3348
# Final stage - minimal runtime image
3449
FROM scratch

Dockerfile.dev

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,26 @@ COPY . .
2828
ARG VERSION=dev
2929
ARG BUILD_TIME
3030
ARG GIT_COMMIT
31-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
31+
# Docker buildx automatically provides these for multi-platform builds
32+
ARG BUILDPLATFORM
33+
ARG TARGETPLATFORM
34+
ARG TARGETOS
35+
ARG TARGETARCH
36+
ARG TARGETVARIANT
37+
38+
# Debug: Show build information
39+
RUN echo "Building for platform: $TARGETPLATFORM (OS: $TARGETOS, Arch: $TARGETARCH, Variant: $TARGETVARIANT)"
40+
RUN echo "Build platform: $BUILDPLATFORM"
41+
RUN echo "Go version: $(go version)"
42+
43+
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \
3244
-ldflags="-s -w -X github.com/kjanat/articulate-parser/internal/version.Version=${VERSION} -X github.com/kjanat/articulate-parser/internal/version.BuildTime=${BUILD_TIME} -X github.com/kjanat/articulate-parser/internal/version.GitCommit=${GIT_COMMIT}" \
3345
-o articulate-parser \
3446
./main.go
3547

48+
# Verify the binary architecture
49+
RUN file /app/articulate-parser || echo "file command not available"
50+
3651
# Development stage - uses Alpine for shell access
3752
FROM alpine:3.21.3
3853

0 commit comments

Comments
 (0)