mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-18 19:49:30 +03:00
Add docker build
This commit is contained in:
parent
a5fbb7b58a
commit
b12feb08bd
9 changed files with 6629 additions and 7 deletions
25
.dockerignore
Normal file
25
.dockerignore
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Node
|
||||
node_modules
|
||||
npm-debug.log
|
||||
|
||||
# Docker
|
||||
Dockerfile*
|
||||
docker-compose*
|
||||
.dockerignore
|
||||
|
||||
# Git
|
||||
.git
|
||||
.gitattributes
|
||||
.gitignore
|
||||
|
||||
# Vscode
|
||||
.vscode
|
||||
*.code-workspace
|
||||
|
||||
# Others
|
||||
.lgtm.yml
|
||||
.travis.yml
|
||||
|
||||
# App data & bin
|
||||
db
|
||||
wireguard-ui
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -15,5 +15,4 @@ wireguard-ui
|
|||
# Dependency directories (remove the comment below to include it)
|
||||
vendor/
|
||||
assets/
|
||||
|
||||
|
||||
node_modules
|
||||
|
|
61
Dockerfile
Normal file
61
Dockerfile
Normal file
|
@ -0,0 +1,61 @@
|
|||
# Build stage
|
||||
FROM golang:1.14.2-alpine3.11 as builder
|
||||
LABEL maintainer="Khanh Ngo <k@ndk.name"
|
||||
ARG BUILD_DEPENDENCIES="npm \
|
||||
yarn"
|
||||
|
||||
# Get dependencies
|
||||
RUN apk add --update --no-cache ${BUILD_DEPENDENCIES}
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# Add sources
|
||||
COPY . /build
|
||||
|
||||
# Get application dependencies and build
|
||||
RUN go mod download
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o wg-ui .
|
||||
|
||||
# Prepare assets
|
||||
RUN yarn install --pure-lockfile --production && \
|
||||
yarn cache clean
|
||||
|
||||
# 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/
|
||||
|
||||
|
||||
# Release stage
|
||||
FROM golang:1.14.2-alpine3.11
|
||||
|
||||
RUN addgroup -S wgui && \
|
||||
adduser -S -D -G wgui wgui
|
||||
|
||||
RUN apk --no-cache add ca-certificates
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN mkdir -p db
|
||||
|
||||
# Copy binary files
|
||||
COPY --from=builder --chown=wgui:wgui /build/wg-ui /app
|
||||
# Copy templates
|
||||
COPY --from=builder --chown=wgui:wgui /build/templates /app/templates
|
||||
# Copy assets
|
||||
COPY --from=builder --chown=wgui:wgui /build/node_modules/admin-lte/dist/js/adminlte.min.js /app/assets/dist/js/adminlte.min.js
|
||||
COPY --from=builder --chown=wgui:wgui /build/node_modules/admin-lte/dist/css/adminlte.min.css /app/assets/dist/css/adminlte.min.css
|
||||
COPY --from=builder --chown=wgui:wgui /assets/plugins /app/assets/plugins
|
||||
|
||||
RUN chmod +x wg-ui
|
||||
|
||||
EXPOSE 5000/tcp
|
||||
HEALTHCHECK CMD ["wget","--output-document=-","--quiet","--tries=1","http://127.0.0.1:5000/"]
|
||||
ENTRYPOINT ["./wg-ui"]
|
13
docker-compose.yaml
Normal file
13
docker-compose.yaml
Normal file
|
@ -0,0 +1,13 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
wg:
|
||||
# image: ngoduykhanh/wireguard-ui:latest
|
||||
image: wgui
|
||||
container_name: wgui
|
||||
ports:
|
||||
- 5000:5000
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: 50m
|
2
main.go
2
main.go
|
@ -33,5 +33,5 @@ func main() {
|
|||
app.GET("/api/machine-ips", handler.MachineIPAddresses())
|
||||
app.GET("/api/suggest-client-ips", handler.SuggestIPAllocation())
|
||||
app.GET("/api/apply-wg-config", handler.ApplyServerConfig())
|
||||
app.Logger.Fatal(app.Start("127.0.0.1:5000"))
|
||||
app.Logger.Fatal(app.Start("0.0.0.0:5000"))
|
||||
}
|
||||
|
|
3427
package-lock.json
generated
Normal file
3427
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
13
package.json
Normal file
13
package.json
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "wireguard-ui",
|
||||
"version": "1.0.0",
|
||||
"description": "Wireguard web interface",
|
||||
"main": "index.js",
|
||||
"repository": "git@github.com:ngoduykhanh/wireguard-ui.git",
|
||||
"author": "Khanh Ngo <k@ndk.name>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"admin-lte": "^3.0",
|
||||
"jquery-tags-input": "^1.3.5"
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
<!-- Toastr -->
|
||||
<link rel="stylesheet" href="static/plugins/toastr/toastr.min.css">
|
||||
<!-- Jquery Tags Input -->
|
||||
<link rel="stylesheet" href="static/plugins/jquery-tags-input/jquery.tagsinput.css">
|
||||
<link rel="stylesheet" href="static/plugins/jquery-tags-input/dist/jquery.tagsinput.min.css">
|
||||
<!-- Ionicons -->
|
||||
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
|
||||
<!-- overlayScrollbars -->
|
||||
|
@ -243,11 +243,9 @@
|
|||
<!-- Toastr -->
|
||||
<script src="static/plugins/toastr/toastr.min.js"></script>
|
||||
<!-- Jquery Tags Input -->
|
||||
<script src="static/plugins/jquery-tags-input/jquery.tagsinput.js"></script>
|
||||
<script src="static/plugins/jquery-tags-input/dist/jquery.tagsinput.min.js"></script>
|
||||
<!-- AdminLTE App -->
|
||||
<script src="static/dist/js/adminlte.min.js"></script>
|
||||
<!-- AdminLTE for demo purposes -->
|
||||
<script src="static/dist/js/demo.js"></script>
|
||||
<script>
|
||||
// submitNewClient function for new client form submition
|
||||
function submitNewClient() {
|
||||
|
|
Loading…
Add table
Reference in a new issue