wireguard-dashboard/Dockerfile

45 lines
881 B
Docker
Raw Permalink Normal View History

2024-06-04 14:47:29 +08:00
# 打包前端
2024-06-04 09:55:48 +08:00
FROM node:18-alpine as build-stage
2024-06-04 10:16:51 +08:00
WORKDIR front
2024-06-04 11:20:55 +08:00
COPY . .
2024-06-04 10:16:51 +08:00
WORKDIR web-src
2024-06-04 09:55:48 +08:00
RUN corepack enable
RUN corepack prepare pnpm@8.6.10 --activate
RUN npm config set registry https://registry.npmmirror.com
2024-06-04 10:45:38 +08:00
RUN pnpm install
2024-06-04 11:50:11 +08:00
RUN pnpm build
2024-06-04 09:55:48 +08:00
2024-06-04 14:47:29 +08:00
# 前后端集成打包
2024-05-08 14:21:49 +08:00
FROM golang:alpine as build
2024-05-08 17:21:52 +08:00
RUN apk add upx
2024-05-08 14:21:49 +08:00
WORKDIR /build
COPY . .
2024-06-04 12:01:00 +08:00
COPY --from=build-stage /front/web/ /build/web
2024-05-08 16:20:52 +08:00
# sqlite必须
2024-05-08 14:21:49 +08:00
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
2024-06-04 16:47:29 +08:00
RUN go build -ldflags="-s -w" -o wgui && upx -9 wgui
2024-05-08 14:21:49 +08:00
2024-06-04 16:47:29 +08:00
RUN ls -lh && chmod +x ./wgui
2024-05-08 14:21:49 +08:00
FROM alpine
2024-06-04 16:47:29 +08:00
RUN addgroup -S wgui && \
adduser -S -D -G wgui wgui
2024-06-04 13:14:18 +08:00
ENV GIN_MODE=release
2024-05-09 11:49:26 +08:00
RUN apk --no-cache add ca-certificates wireguard-tools jq iptables
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-06-04 16:47:29 +08:00
COPY --from=build --chown=wgui:wgui /build/wgui /app
2024-05-08 14:59:40 +08:00
COPY --from=build /build/template/* /app/template/
2024-05-08 14:21:49 +08:00
2024-06-04 16:47:29 +08:00
RUN chmod +x wgui
2024-06-04 16:49:58 +08:00
ENTRYPOINT ["./wgui"]