我想要为它构建docker图像的golang应用程序
名为cloud-native-go
的应用程序文件夹和dockerfile位于根项目下
知道这里有什么问题吗?
FROM golang:alpine3.7
WORKDIR /go/src/app
COPY . .
RUN apk add --no-cache git
RUN go-wrapper download # "go get -d -v ./..."
RUN go-wrapper install # "go install -v ./..."
#final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /go/bin/app /app
ENTRYPOINT ./app
LABEL Name=cloud-native-go Version=0.0.1
EXPOSE 3000
错误是:
Step 5/12 : RUN go-wrapper download # "go get -d -v ./..."
---> Running in 70c2e00f332d
/bin/sh: go-wrapper: not found
我用
构建它 docker build -t cloud-native-go:1.0.0 .
答案 0 :(得分:2)
go-wrapper
已被弃用,并使用go
版本10及更高版本从图像中删除。见here。
如果使用go v1.9
表现良好,可以使用下面的图片:golang:1.9.6-alpine3.7
。
所以你的Dockerfile
将是:
FROM golang:1.9.6-alpine3.7
WORKDIR /go/src/app
COPY . .
RUN apk add --no-cache git
RUN go-wrapper download # "go get -d -v ./..."
RUN go-wrapper install # "go install -v ./..."
#final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /go/bin/app /app
ENTRYPOINT ./app
LABEL Name=cloud-native-go Version=0.0.1
EXPOSE 3000
答案 1 :(得分:0)
FROM golang:alpine
# important!
ENV GO111MODULE=on
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
ENV GOFLAGS=-mod=vendor
ENV APP_USER app
ENV APP_HOME /go/src/microservices
RUN mkdir /nameApp
ADD . /nameApp
WORKDIR /nameApp
//compile your project
RUN go mod vendor
RUN go build
//open the port 8000
EXPOSE 8000
CMD [ "/nameApp/nameApp" ]