FROM golang:1.19 as builder RUN echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib\n\ deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib\n\ deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib\n\ deb-src http://mirrors.163.com/debian/ jessie main non-free contrib\n\ deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib\n\ deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib\n\ deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib\n\ deb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib\n\ deb http://ftp.cn.debian.org/debian jessie main" > /etc/apt/sources.list # install gcc RUN apt-get update && apt-get install -y --no-install-recommends \ g++ \ gcc \ libc6-dev \ make \ pkg-config \ && apt-get install -y curl git unzip vim iputils-ping wget \ && rm -rf /var/lib/apt/lists/* WORKDIR /workspaces COPY . ./ ENV GOPROXY=https://goproxy.cn,direct RUN go get -d -v ./ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -o demo -ldflags="-w -s" main.go FROM alpine:latest as runner WORKDIR /app COPY --from=builder /app/main . COPY --from=builder /app/config ./config RUN echo "https://mirrors.aliyun.com/alpine/v3.8/main/" > /etc/apk/repositories \ && echo "https://mirrors.aliyun.com/alpine/v3.8/community/" >> /etc/apk/repositories \ && apk add --no-cache tzdata \ && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo Asia/Shanghai > /etc/timezone \ && apk del tzdata EXPOSE 8888 VOLUME ["/app/config","/app/log", "/workspaces"] ENTRYPOINT ["./main"] # CMD [ "/app/demo" ] CMD [ "/bin/bash" ]