wireguard-dashboard/Dockerfile
coward d942de22de
All checks were successful
continuous-integration/drone/tag Build is passing
🎨优化
2024-06-04 16:49:58 +08:00

45 lines
881 B
Docker

# 打包前端
FROM node:18-alpine as build-stage
WORKDIR front
COPY . .
WORKDIR web-src
RUN corepack enable
RUN corepack prepare pnpm@8.6.10 --activate
RUN npm config set registry https://registry.npmmirror.com
RUN pnpm install
RUN pnpm build
# 前后端集成打包
FROM golang:alpine as build
RUN apk add upx
WORKDIR /build
COPY . .
COPY --from=build-stage /front/web/ /build/web
# sqlite必须
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
RUN go build -ldflags="-s -w" -o wgui && upx -9 wgui
RUN ls -lh && chmod +x ./wgui
FROM alpine
RUN addgroup -S wgui && \
adduser -S -D -G wgui wgui
ENV GIN_MODE=release
RUN apk --no-cache add ca-certificates wireguard-tools jq iptables
WORKDIR /app
RUN mkdir -p db
COPY --from=build --chown=wgui:wgui /build/wgui /app
COPY --from=build /build/template/* /app/template/
RUN chmod +x wgui
ENTRYPOINT ["./wgui"]