- 在 config.go 中增加对环境变量的读取逻辑 - 更新 Dockerfile,添加新的环境变量 - 移除 views/merchant.html 中的多余支付选项 - 在 supplier.go 中添加新的供应商 "七喜"
52 lines
1.3 KiB
Docker
52 lines
1.3 KiB
Docker
FROM golang:1.23 AS builder
|
|
|
|
# 定义参数
|
|
ARG USE_PROXY
|
|
|
|
WORKDIR /build
|
|
COPY .. /build/
|
|
|
|
# 根据USE_PROXY参数设置环境变量
|
|
RUN if [ "$USE_PROXY" = "1" ]; then \
|
|
export GOPROXY=https://goproxy.cn,direct; \
|
|
# else \
|
|
# export GOPROXY=direct; \
|
|
fi \
|
|
&& export GO111MODULE=on \
|
|
&& export CGO_ENABLED=0 \
|
|
&& export GOOS=linux \
|
|
&& export GOARCH=amd64 \
|
|
&& go mod tidy && go build main.go
|
|
|
|
FROM alpine:latest
|
|
|
|
WORKDIR /app
|
|
ENV TZ=Asia/Shanghai
|
|
ENV serverName=""
|
|
ENV gatewayAddr=""
|
|
ENV portalAddr=""
|
|
|
|
# 定义参数
|
|
ARG USE_PROXY
|
|
|
|
#设置国内镜像源,时区
|
|
RUN if [ "$USE_PROXY" = "1" ]; then \
|
|
echo "https://mirrors.aliyun.com/alpine/v3.18/main/" > /etc/apk/repositories && \
|
|
echo "https://mirrors.aliyun.com/alpine/v3.18/community/" >> /etc/apk/repositories; \
|
|
fi && \
|
|
apk update && \
|
|
apk upgrade && \
|
|
apk add --no-cache tzdata && \
|
|
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
echo "Asia/Shanghai" > /etc/timezone
|
|
|
|
COPY --from=builder /build/main /app/
|
|
COPY --from=builder /build/conf/ /app/conf/
|
|
COPY --from=builder /build/views/ /app/views/
|
|
COPY --from=builder /build/static/ /app/static/
|
|
COPY --from=builder /build/deploy/wait-for-it.sh /app/
|
|
|
|
# 启动服务
|
|
CMD ["sh", "wait-for-it.sh", "mysql:3306" , "./main"]
|
|
|
|
EXPOSE 12306 |