Skip to content

Commit 41fe554

Browse files
Merge pull request #33 from iAmBipinPaul/main
fix(docker): compile goose for target architecture to prevent ARM exec-format errors
2 parents 5f36f26 + 00c9334 commit 41fe554

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,19 @@ RUN if [ ! -f .env ]; then \
2121
RUN npm run build
2222

2323
# ========= BUILD BACKEND =========
24+
# Backend build stage
2425
FROM --platform=$BUILDPLATFORM golang:1.23.3 AS backend-build
2526

26-
# Install Go public tools needed in runtime
27-
RUN curl -fsSL https://raw.githubusercontent.com/pressly/goose/master/install.sh | sh
27+
# Make TARGET args available early so tools built here match the final image arch
28+
ARG TARGETOS
29+
ARG TARGETARCH
30+
31+
# Install Go public tools needed in runtime. Use `go install` for goose so the
32+
# binary is compiled for the target architecture instead of downloading a
33+
# prebuilt binary which may have the wrong architecture (causes exec format
34+
# errors on ARM).
35+
RUN env GOBIN=/usr/local/bin GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
36+
go install github.com/pressly/goose/v3/cmd/goose@latest
2837
RUN go install github.com/swaggo/swag/cmd/[email protected]
2938

3039
# Set working directory
@@ -168,4 +177,4 @@ EXPOSE 4005
168177
VOLUME ["/postgresus-data"]
169178

170179
ENTRYPOINT ["/app/start.sh"]
171-
CMD []
180+
CMD []

0 commit comments

Comments
 (0)