【发布时间】:2022-02-15 18:55:31
【问题描述】:
我需要从文件“cert.pem”中读取我的应用程序,该文件的路径是 a) 作为参数提供或 b) 从主应用程序文件 main.py 的目录中检索。
我创建了以下 dockerfile,但在使用映像构建和运行我的应用程序后,无法访问“cert.pem”文件。有没有办法从这个文件中读取?
FROM golang:1.17-alpine AS builder
RUN apk add --no-cache git
WORKDIR /app
COPY . .
RUN go mod download
RUN go build -o ./bin .
#final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /app/bin /app/bin
EXPOSE 3000
CMD ["/app/bin"]
加载文件的指令如下:
....
var (
cert_file = flag.String("cert", "./cert.pem", "File name of x509 certificate")
)
...
func main() {
...
_, err := ioutil.ReadFile(*cert_file)
...
【问题讨论】:
标签: dockerfile dependencies docker-multi-stage-build