Skip to content

Commit

Permalink
fix: build statically linked binaries (#1681)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwotherspoon authored Feb 23, 2023
1 parent 865b747 commit ccb9bfa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# Use the latest stable golang 1.x to compile to a binary
FROM --platform=$BUILDPLATFORM golang:1 as build
FROM --platform=$BUILDPLATFORM golang:1-alpine as build

WORKDIR /go/src/cloudsql-proxy
COPY . .
Expand All @@ -22,7 +22,7 @@ ARG TARGETOS
ARG TARGETARCH

RUN go get ./...
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -ldflags "-X main.metadataString=container.alpine" -o cloud_sql_proxy ./cmd/cloud_sql_proxy

# Final stage
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.bullseye
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ARG TARGETOS
ARG TARGETARCH

RUN go get ./...
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -ldflags "-X main.metadataString=container.bullseye" -o cloud_sql_proxy ./cmd/cloud_sql_proxy

# Final stage
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.buster
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ARG TARGETOS
ARG TARGETARCH

RUN go get ./...
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -ldflags "-X main.metadataString=container.buster" -o cloud_sql_proxy ./cmd/cloud_sql_proxy

# Final stage
Expand Down

0 comments on commit ccb9bfa

Please sign in to comment.