forked from ngoduykhanh/wireguard-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
75 lines (57 loc) · 1.9 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Build stage
FROM node:latest as frontend
WORKDIR /build
COPY package.json /build
COPY yarn.lock /build
# Prepare assets
RUN yarn install
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:bookworm as builder
LABEL maintainer="Khanh Ngo <[email protected]>"
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
ARG APP_VERSION=dev
ARG BUILD_TIME
ARG GIT_COMMIT
# Get dependencies
WORKDIR /build
# Add dependencies
COPY go.mod /build
COPY go.sum /build
COPY --from=frontend /build/node_modules /build/node_modules
# Move admin-lte dist
RUN mkdir -p assets/dist/js assets/dist/css && \
cp /build/node_modules/admin-lte/dist/js/adminlte.min.js \
assets/dist/js/adminlte.min.js && \
cp /build/node_modules/admin-lte/dist/css/adminlte.min.css \
assets/dist/css/adminlte.min.css
# Move plugin assets
RUN mkdir -p assets/plugins && \
cp -r /build/node_modules/admin-lte/plugins/jquery/ \
/build/node_modules/admin-lte/plugins/fontawesome-free/ \
/build/node_modules/admin-lte/plugins/bootstrap/ \
/build/node_modules/admin-lte/plugins/icheck-bootstrap/ \
/build/node_modules/admin-lte/plugins/toastr/ \
/build/node_modules/admin-lte/plugins/jquery-validation/ \
/build/node_modules/admin-lte/plugins/select2/ \
/build/node_modules/jquery-tags-input/ \
assets/plugins/
# Add sources
COPY . /build
# Move custom assets
RUN cp -r /build/custom/ assets/
# Build
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-X 'main.appVersion=${APP_VERSION}' -X 'main.buildTime=${BUILD_TIME}' -X 'main.gitCommit=${GIT_COMMIT}'" -a -o wg-ui .
# Release stage
FROM debian:stable-slim
RUN useradd wgui
RUN apt-get update
RUN apt-get install -y ca-certificates wireguard jq iproute2 inotify-tools iptables
WORKDIR /app
RUN mkdir -p db
# Copy binary files
COPY --from=builder --chown=wgui:wgui /build/wg-ui .
RUN chmod +x wg-ui
COPY init.sh .
EXPOSE 5000/tcp
ENTRYPOINT ["./init.sh"]