2024-05-08 14:21:49 +08:00
|
|
|
FROM golang:alpine as build
|
|
|
|
|
2024-05-08 16:44:46 +08:00
|
|
|
RUN apk add upx && apk add build-base
|
2024-05-08 14:33:40 +08:00
|
|
|
|
2024-05-08 14:21:49 +08:00
|
|
|
WORKDIR /build
|
|
|
|
|
|
|
|
COPY . .
|
2024-05-08 16:20:52 +08:00
|
|
|
# sqlite必须
|
2024-05-08 16:52:22 +08:00
|
|
|
ENV CGO_ENABLED=1
|
2024-05-08 14:21:49 +08:00
|
|
|
ENV GO111MODULE=on
|
|
|
|
ENV GOPROXY=https://goproxy.cn,direct
|
|
|
|
|
2024-05-08 16:52:22 +08:00
|
|
|
RUN go build -ldflags="-s -w" -installsuffix cgo -o app && up -9 app
|
2024-05-08 14:21:49 +08:00
|
|
|
|
|
|
|
RUN ls -lh && chmod +x ./app
|
|
|
|
|
|
|
|
FROM alpine
|
|
|
|
|
2024-05-08 14:59:40 +08:00
|
|
|
WORKDIR /app
|
2024-05-08 15:51:19 +08:00
|
|
|
RUN mkdir -p db
|
2024-05-08 14:21:49 +08:00
|
|
|
|
2024-05-08 14:59:40 +08:00
|
|
|
COPY --from=build /build/app /app
|
|
|
|
COPY --from=build /build/template/* /app/template/
|
2024-05-08 14:21:49 +08:00
|
|
|
|
2024-05-08 16:20:52 +08:00
|
|
|
RUN ls -al
|
2024-05-08 14:59:40 +08:00
|
|
|
|
2024-05-08 15:51:19 +08:00
|
|
|
ENTRYPOINT ["./app"]
|