You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
708 B
Docker

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

FROM golang:1.20 as builder
# 指定构建过程中的工作目录
WORKDIR /app
# 将当前目录dockerfile所在目录下所有文件都拷贝到工作目录下.dockerignore中文件除外
COPY . /app/
# 执行代码编译命令。操作系统参数为linux编译后的二进制产物命名为main并存放在当前目录下。
RUN GOPROXY=https://goproxy.cn,direct GOOS=linux GOARCH=amd64 go build -gcflags "all=-N -l" -o main -mod=vendor cmd/main/main.go
FROM public-cn-beijing.cr.volces.com/public/base:alpine-3.13
WORKDIR /opt/application
COPY --from=builder /app/main /app/run.sh /opt/application/
USER root
RUN chmod -R 777 /opt/application/run.sh
CMD /opt/application/run.sh