Skip to content

Commit b12feb0

Browse files
committed
Add docker build
1 parent a5fbb7b commit b12feb0

9 files changed

+6629
-7
lines changed

.dockerignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Node
2+
node_modules
3+
npm-debug.log
4+
5+
# Docker
6+
Dockerfile*
7+
docker-compose*
8+
.dockerignore
9+
10+
# Git
11+
.git
12+
.gitattributes
13+
.gitignore
14+
15+
# Vscode
16+
.vscode
17+
*.code-workspace
18+
19+
# Others
20+
.lgtm.yml
21+
.travis.yml
22+
23+
# App data & bin
24+
db
25+
wireguard-ui

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ wireguard-ui
1515
# Dependency directories (remove the comment below to include it)
1616
vendor/
1717
assets/
18-
19-
18+
node_modules

Dockerfile

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Build stage
2+
FROM golang:1.14.2-alpine3.11 as builder
3+
LABEL maintainer="Khanh Ngo <[email protected]"
4+
ARG BUILD_DEPENDENCIES="npm \
5+
yarn"
6+
7+
# Get dependencies
8+
RUN apk add --update --no-cache ${BUILD_DEPENDENCIES}
9+
10+
WORKDIR /build
11+
12+
# Add sources
13+
COPY . /build
14+
15+
# Get application dependencies and build
16+
RUN go mod download
17+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o wg-ui .
18+
19+
# Prepare assets
20+
RUN yarn install --pure-lockfile --production && \
21+
yarn cache clean
22+
23+
# Move plugin assets
24+
RUN mkdir -p /assets/plugins && \
25+
cp -r /build/node_modules/admin-lte/plugins/jquery/ \
26+
/build/node_modules/admin-lte/plugins/fontawesome-free/ \
27+
/build/node_modules/admin-lte/plugins/bootstrap/ \
28+
/build/node_modules/admin-lte/plugins/icheck-bootstrap/ \
29+
/build/node_modules/admin-lte/plugins/toastr/ \
30+
/build/node_modules/admin-lte/plugins/jquery-validation/ \
31+
/build/node_modules/admin-lte/plugins/select2/ \
32+
/build/node_modules/jquery-tags-input/ \
33+
/assets/plugins/
34+
35+
36+
# Release stage
37+
FROM golang:1.14.2-alpine3.11
38+
39+
RUN addgroup -S wgui && \
40+
adduser -S -D -G wgui wgui
41+
42+
RUN apk --no-cache add ca-certificates
43+
44+
WORKDIR /app
45+
46+
RUN mkdir -p db
47+
48+
# Copy binary files
49+
COPY --from=builder --chown=wgui:wgui /build/wg-ui /app
50+
# Copy templates
51+
COPY --from=builder --chown=wgui:wgui /build/templates /app/templates
52+
# Copy assets
53+
COPY --from=builder --chown=wgui:wgui /build/node_modules/admin-lte/dist/js/adminlte.min.js /app/assets/dist/js/adminlte.min.js
54+
COPY --from=builder --chown=wgui:wgui /build/node_modules/admin-lte/dist/css/adminlte.min.css /app/assets/dist/css/adminlte.min.css
55+
COPY --from=builder --chown=wgui:wgui /assets/plugins /app/assets/plugins
56+
57+
RUN chmod +x wg-ui
58+
59+
EXPOSE 5000/tcp
60+
HEALTHCHECK CMD ["wget","--output-document=-","--quiet","--tries=1","http://127.0.0.1:5000/"]
61+
ENTRYPOINT ["./wg-ui"]

docker-compose.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '3'
2+
3+
services:
4+
wg:
5+
# image: ngoduykhanh/wireguard-ui:latest
6+
image: wgui
7+
container_name: wgui
8+
ports:
9+
- 5000:5000
10+
logging:
11+
driver: json-file
12+
options:
13+
max-size: 50m

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ func main() {
3333
app.GET("/api/machine-ips", handler.MachineIPAddresses())
3434
app.GET("/api/suggest-client-ips", handler.SuggestIPAllocation())
3535
app.GET("/api/apply-wg-config", handler.ApplyServerConfig())
36-
app.Logger.Fatal(app.Start("127.0.0.1:5000"))
36+
app.Logger.Fatal(app.Start("0.0.0.0:5000"))
3737
}

0 commit comments

Comments
 (0)