Skip to content

Commit b61eddb

Browse files
authored
Update Dockerfile to adaption Cross-compiling
1 parent 5c8d405 commit b61eddb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
FROM opencsg-registry.cn-beijing.cr.aliyuncs.com/opencsg_public/go-node AS build
1+
FROM --platform=$BUILDPLATFORM opencsg-registry.cn-beijing.cr.aliyuncs.com/opencsg_public/go-node AS builder
22
RUN mkdir /myapp
33
WORKDIR /myapp
44
ADD . /myapp
55

6+
ENV CGO_ENABLED=0
67
RUN go mod tidy
78
RUN cd frontend && yarn install && yarn build
8-
RUN go build -o csghub-portal ./cmd/csghub-portal
9+
RUN GOOS=$(echo ${TARGETPLATFORM} | cut -f1 -d '/') \
10+
GOARCH=$(echo ${TARGETPLATFORM} | cut -f2 -d '/') \
11+
go build -o csghub-portal ./cmd/csghub-portal
912

1013
FROM bitnami/minideb:latest
1114
RUN apt update && apt install -y ca-certificates && update-ca-certificates
1215
WORKDIR /myapp
13-
COPY --from=build /myapp/csghub-portal /myapp/csghub-portal
16+
COPY --from=builder /myapp/csghub-portal /myapp/csghub-portal

0 commit comments

Comments
 (0)