.gitignore
This commit is contained in:
44
Dockerfile
44
Dockerfile
@@ -1,46 +1,48 @@
|
||||
FROM golang:1.25.5-alpine AS builder
|
||||
# 阶段1: 构建
|
||||
FROM golang:1.25-alpine AS builder
|
||||
|
||||
# 配置Alpine国内镜像源(加速apk)
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
&& apk add --no-cache git
|
||||
RUN apk add --no-cache git ca-certificates tzdata
|
||||
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
ENV CGO_ENABLED=0
|
||||
ENV GOPRIVATE=gitee.com/red-future---jilin-g/*
|
||||
|
||||
ARG GITEE_TOKEN
|
||||
RUN git config --global url."https://oauth2:cf5eb6b356c7040747eb5eda8b48a617@gitee.com/".insteadOf "https://gitee.com/"
|
||||
ENV GOTOOLCHAIN=auto
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
COPY ../../../../../Downloads/未命名文件夹 .
|
||||
COPY go.mod go.sum ./
|
||||
COPY common ./common
|
||||
|
||||
# 强制更新 common 包到 master 最新版本
|
||||
RUN go get -u gitee.com/red-future---jilin-g/common@master
|
||||
RUN go mod download
|
||||
|
||||
RUN go mod tidy && go mod download
|
||||
COPY main.go ./
|
||||
COPY config.yml ./
|
||||
|
||||
RUN go build -ldflags="-s -w" -o main ./main.go
|
||||
|
||||
FROM alpine:latest
|
||||
# 阶段2: 运行
|
||||
FROM alpine:3.19
|
||||
|
||||
# 配置Alpine国内镜像源(加速apk)
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
RUN apk add --no-cache ca-certificates tzdata
|
||||
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN apk add --no-cache tzdata \
|
||||
&& ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
|
||||
&& echo $TZ > /etc/timezone
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /build/main .
|
||||
COPY --from=builder /build/config.yml .
|
||||
COPY --from=builder /build/config.yml ./
|
||||
|
||||
RUN mkdir -p /app/resource/log/run \
|
||||
/app/resource/log/server \
|
||||
&& adduser -D -u 1000 appuser \
|
||||
&& chown -R appuser:appuser /app
|
||||
|
||||
RUN adduser -D -u 1000 appuser
|
||||
USER appuser
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["./main"]
|
||||
CMD ["./main"]
|
||||
|
||||
Reference in New Issue
Block a user