chore(init): 初始化解忧商行项目并完成 Phase 0 基座
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
FROM golang:1.26-alpine AS build
|
||||
|
||||
WORKDIR /src
|
||||
ARG GOOSE_VERSION=v3.27.1
|
||||
ARG GOPROXY=https://goproxy.cn,direct
|
||||
ARG GOSUMDB=sum.golang.google.cn
|
||||
ENV GOPROXY=${GOPROXY} \
|
||||
GOSUMDB=${GOSUMDB}
|
||||
|
||||
COPY go.mod go.sum* ./
|
||||
RUN --mount=type=cache,target=/go/pkg/mod go mod download
|
||||
COPY . .
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
go install github.com/pressly/goose/v3/cmd/goose@${GOOSE_VERSION}
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
CGO_ENABLED=0 GOOS=linux go build -o /out/hfb-api ./cmd/api
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
CGO_ENABLED=0 GOOS=linux go build -o /out/hfb-storage-migrate ./cmd/storage-migrate
|
||||
# 一次性运维脚本:线下提号邀请返利补发(默认预演,-apply 才写库)
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
CGO_ENABLED=0 GOOS=linux go build -o /out/hfb-rebate-backfill ./cmd/rebate-backfill
|
||||
|
||||
FROM alpine:3.22
|
||||
|
||||
WORKDIR /app
|
||||
ENV TZ=Asia/Shanghai
|
||||
# 国内服务器访问 dl-cdn.alpinelinux.org 常极慢,改用阿里云镜像
|
||||
RUN sed -i 's#https\?://dl-cdn.alpinelinux.org/alpine#https://mirrors.aliyun.com/alpine#g' \
|
||||
/etc/apk/repositories \
|
||||
&& apk add --no-cache tzdata \
|
||||
&& addgroup -S -g 10001 app \
|
||||
&& adduser -S -D -H -u 10001 -G app app \
|
||||
&& mkdir -p /app/logs \
|
||||
&& chown app:app /app/logs
|
||||
COPY --from=build /out/hfb-api /app/hfb-api
|
||||
COPY --from=build /out/hfb-storage-migrate /app/hfb-storage-migrate
|
||||
COPY --from=build /out/hfb-rebate-backfill /app/hfb-rebate-backfill
|
||||
COPY --from=build /go/bin/goose /app/goose
|
||||
COPY --from=build /src/migrations /app/migrations
|
||||
USER app:app
|
||||
EXPOSE 8080
|
||||
CMD ["/app/hfb-api"]
|
||||
Reference in New Issue
Block a user