2024-06-18 18:14:57 +08:00
|
|
|
FROM golang:1.21.10-alpine AS builder
|
|
|
|
|
|
|
|
LABEL stage=gobuilder
|
2024-06-18 18:33:34 +08:00
|
|
|
|
2024-06-18 18:14:57 +08:00
|
|
|
ENV CGO_ENABLED 0
|
|
|
|
ENV GOPROXY https://goproxy.cn,direct
|
2024-06-18 18:33:34 +08:00
|
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
|
|
|
|
|
|
|
RUN apk update --no-cache && apk add --no-cache tzdata
|
|
|
|
|
2024-06-19 10:55:54 +08:00
|
|
|
WORKDIR /src
|
2024-06-18 18:14:57 +08:00
|
|
|
|
|
|
|
COPY ../.. .
|
2024-06-19 10:55:54 +08:00
|
|
|
RUN go mod tidy
|
2024-06-18 18:14:57 +08:00
|
|
|
RUN go build -ldflags="-s -w" -o /src/cmd/api/transfer cmd/api/transfer.go
|
|
|
|
|
|
|
|
|
|
|
|
FROM alpine:latest AS runtime
|
|
|
|
|
2024-06-18 18:33:34 +08:00
|
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
|
|
|
|
2024-06-18 18:14:57 +08:00
|
|
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
2024-06-18 18:33:34 +08:00
|
|
|
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
|
|
|
|
ENV TZ Asia/Shanghai
|
2024-06-18 18:14:57 +08:00
|
|
|
COPY --from=builder /src /src
|
2024-06-18 18:33:34 +08:00
|
|
|
RUN apk update --no-cache && apk add --no-cache supervisor
|
|
|
|
RUN apk add --no-cache make
|
|
|
|
|
|
|
|
|
2024-06-18 18:14:57 +08:00
|
|
|
|
|
|
|
RUN mkdir "/var/log/supervisor"
|
2024-06-18 18:33:34 +08:00
|
|
|
|
2024-06-18 18:14:57 +08:00
|
|
|
ADD ./sh/startup.sh /opt/startup.sh
|
|
|
|
RUN sed -i 's/\r//g' /opt/startup.sh
|
|
|
|
ADD ./sh/supervisord.conf /etc/supervisord.conf
|
|
|
|
|
|
|
|
WORKDIR /src
|
2024-06-18 18:23:48 +08:00
|
|
|
EXPOSE 10101
|
2024-06-18 18:14:57 +08:00
|
|
|
#CMD ["sh","/opt/startup.sh"]
|