从第一阶段开始使用文件夹构建Docker多阶段

时间:2019-06-04 14:00:55

标签: linux docker dockerfile docker-multi-stage-build

我有以下工作正常的docker文件,我使用多阶段构建 而“跑步者”使用FROM golang:1.11.4-alpine3.8

FROM golang:1.11.4-alpine3.8 AS builder
ENV SOURCES /github/myapp
RUN apk add --update --no-cache make curl \
    git

ADD https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 /usr/bin/dep
RUN chmod +x /usr/bin/dep

WORKDIR  $GOPATH/src/${SOURCES}
COPY Gopkg.toml Gopkg.lock ./
RUN dep ensure 

# Copy project
COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o bin .

# Runner
FROM golang:1.11.4-alpine3.8

RUN apk add --update --no-cache curl \

# Install CA cert
RUN curl -sSL -f -k http://aia.pki.vs.com/aia/0CA.crt -o /usr/share/pki/trust/anchors/CA.crt && \
    update-ca-certificates

COPY --from=builder /bin ./

现在,我想更改跑步者阶段以使用刮刮图像并尝试如下操作:


FROM golang:1.11.4-alpine3.8 AS builder
ENV SOURCES /github/myapp
RUN apk add --update --no-cache make curl \
    git

ADD https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 /usr/bin/dep
RUN chmod +x /usr/bin/dep

# Install CA cert
RUN curl -sSL -f -k http://aia.pki.vs.com/aia/0CA.crt -o /usr/share/pki/trust/anchors/CA.crt && \
    update-ca-certificates

WORKDIR  $GOPATH/src/${SOURCES}
COPY Gopkg.toml Gopkg.lock ./
RUN dep ensure 

# Copy project
COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o bin .

# THIS IS THE CHANGE
FROM scratch


COPY --from=builder /bin ./
COPY --from=builder /usr/share/pki/trust/anchors/CA.crt /usr/share/pki/trust/anchors/CA.crt
ENTRYPOINT [“./bin”]

错误是

curl: (23) Failed writing body (0 != 1132)

我需要的是也将证书(不仅仅是bin)从第一阶段复制到第二阶段,并使用从头开始图片

0 个答案:

没有答案