123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- # FROM golang:1.21.3-alpine3.18 as builder
- # ENV GOPROXY https://goproxy.cn/
- # WORKDIR /go/release
- # COPY go.mod ./go.mod
- # RUN go mod tidy
- # COPY . .
- # RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -a -installsuffix cgo -o observe .
- FROM reg.cestong.com.cn/cecf/golang:1.23.1-alpine3.20 AS builder
- WORKDIR /src
- COPY . .
- ENV GOPROXY=https://goproxy.cn/
- RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && \
- apk add --no-cache make && \
- apk add --no-cache git
- # RUN --mount=type=cache,target=/go/pkg/mod/ make build
- RUN --mount=type=cache,target=/go/pkg/mod/ make build
- FROM reg.cestong.com.cn/cecf/alpine:3.20
- # RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
- # RUN apk add --no-cache tzdata
- # ENV TZ=Asia/Shanghai
- COPY --from=builder /src/bin/observe /app/observe
- COPY --from=builder /src/config/settings.yml /app/settings.yml
- COPY --from=builder /src/version /app/version
- # COPY bin/observe /app/observe
- # COPY ./config/settings.yml /app/settings.yml
- # COPY ./version /app/version
- EXPOSE 8000
- # RUN chmod +x /app/observe # 这条命令会将镜像大小翻倍,copy过来时就是可执行的,不需要多此一举
- CMD ["/app/observe","server","-c", "/app/settings.yml"]
- # FROM golang:1.19.3
- # ENV GOPROXY https://goproxy.cn/
- # RUN apt install apt-transport-https ca-certificates
- # RUN apt-get update && apt-get install -yq tzdata vim iputils-ping net-tools telnet iotop
- # ENV TZ="Asia/Shanghai"
- # RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
- # RUN dpkg-reconfigure -f noninteractive tzdata
- # RUN mkdir -p /app
- # COPY bin/observe /app/observe
- # COPY ./config /app/config
- # COPY ./version /app/version
- # EXPOSE 8000
- # RUN chmod +x /app/observe
- # CMD ["/app/observe","server","-c", "/app/settings.yml"]
|