wireguard-dashboard/Dockerfile

46 lines
925 B
Docker
Raw Permalink Normal View History

2024-08-21 09:10:01 +08:00
# 打包前端
FROM node:18-alpine as build-front
WORKDIR front
COPY . .
WORKDIR web
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
2024-08-21 09:22:58 +08:00
RUN ls -lh && pwd
2024-08-21 09:10:01 +08:00
2024-08-20 10:34:22 +08:00
# 前后端集成打包
2024-08-21 09:10:01 +08:00
FROM golang:alpine as build-backend
2024-08-20 10:34:22 +08:00
RUN apk add upx
WORKDIR /build
COPY . .
2024-08-21 09:22:58 +08:00
COPY --from=build-front /front/web/dist/ /build/dist
2024-08-20 10:34:22 +08:00
# 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
2024-08-21 09:10:01 +08:00
COPY --from=build-backend --chown=wgui:wgui /build/wgui /app
COPY --from=build-backend /build/template/* /app/template/
2024-08-20 10:34:22 +08:00
RUN chmod +x wgui
ENTRYPOINT ["./wgui"]