Skip to content

Commit 523267e

Browse files
committed
fix: disable CGO in binary builds
1 parent e96a2bc commit 523267e

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/nightly.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ jobs:
7979
run: |
8080
cp -r frontend/dist internal/assets/dist
8181
go build -ldflags "-s -w -X tinyauth/internal/constants.Version=${{ needs.generate-metadata.outputs.VERSION }} -X tinyauth/internal/constants.CommitHash=${{ needs.generate-metadata.outputs.COMMIT_HASH }} -X tinyauth/internal/constants.BuildTimestamp=${{ needs.generate-metadata.outputs.BUILD_TIMESTAMP }}" -o tinyauth-amd64
82+
env:
83+
CGO_ENABLED: 0
8284

8385
- name: Upload artifact
8486
uses: actions/upload-artifact@v4
@@ -123,6 +125,8 @@ jobs:
123125
run: |
124126
cp -r frontend/dist internal/assets/dist
125127
go build -ldflags "-s -w -X tinyauth/internal/constants.Version=${{ needs.generate-metadata.outputs.VERSION }} -X tinyauth/internal/constants.CommitHash=${{ needs.generate-metadata.outputs.COMMIT_HASH }} -X tinyauth/internal/constants.BuildTimestamp=${{ needs.generate-metadata.outputs.BUILD_TIMESTAMP }}" -o tinyauth-arm64
128+
env:
129+
CGO_ENABLED: 0
126130

127131
- name: Upload artifact
128132
uses: actions/upload-artifact@v4

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ jobs:
5959
run: |
6060
cp -r frontend/dist internal/assets/dist
6161
go build -ldflags "-s -w -X tinyauth/internal/constants.Version=${{ needs.generate-metadata.outputs.VERSION }} -X tinyauth/internal/constants.CommitHash=${{ needs.generate-metadata.outputs.COMMIT_HASH }} -X tinyauth/internal/constants.BuildTimestamp=${{ needs.generate-metadata.outputs.BUILD_TIMESTAMP }}" -o tinyauth-amd64
62+
env:
63+
CGO_ENABLED: 0
6264

6365
- name: Upload artifact
6466
uses: actions/upload-artifact@v4
@@ -100,6 +102,8 @@ jobs:
100102
run: |
101103
cp -r frontend/dist internal/assets/dist
102104
go build -ldflags "-s -w -X tinyauth/internal/constants.Version=${{ needs.generate-metadata.outputs.VERSION }} -X tinyauth/internal/constants.CommitHash=${{ needs.generate-metadata.outputs.COMMIT_HASH }} -X tinyauth/internal/constants.BuildTimestamp=${{ needs.generate-metadata.outputs.BUILD_TIMESTAMP }}" -o tinyauth-arm64
105+
env:
106+
CGO_ENABLED: 0
103107

104108
- name: Upload artifact
105109
uses: actions/upload-artifact@v4

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ COPY ./cmd ./cmd
3838
COPY ./internal ./internal
3939
COPY --from=frontend-builder /frontend/dist ./internal/assets/dist
4040

41-
RUN go build -ldflags "-s -w -X tinyauth/internal/constants.Version=${VERSION} -X tinyauth/internal/constants.CommitHash=${COMMIT_HASH} -X tinyauth/internal/constants.BuildTimestamp=${BUILD_TIMESTAMP}"
41+
RUN CGO_ENABLED=0 go build -ldflags "-s -w -X tinyauth/internal/constants.Version=${VERSION} -X tinyauth/internal/constants.CommitHash=${COMMIT_HASH} -X tinyauth/internal/constants.BuildTimestamp=${BUILD_TIMESTAMP}"
4242

4343
# Runner
4444
FROM alpine:3.22 AS runner

air.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tmp_dir = "tmp"
33

44
[build]
55
pre_cmd = ["mkdir -p internal/assets/dist", "echo 'backend running' > internal/assets/dist/index.html"]
6-
cmd = "go build -o ./tmp/tinyauth ."
6+
cmd = "CGO_ENABLED=0 go build -o ./tmp/tinyauth ."
77
bin = "tmp/tinyauth"
88
include_ext = ["go"]
99
exclude_dir = ["internal/assets/dist"]

0 commit comments

Comments
 (0)