mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-21 20:12:33 +03:00
Adjust dockerfile
This commit is contained in:
parent
af16649b3f
commit
d428bfe6f4
3 changed files with 46 additions and 12 deletions
26
Dockerfile
26
Dockerfile
|
@ -12,14 +12,17 @@ WORKDIR /build
|
||||||
# Add sources
|
# Add sources
|
||||||
COPY . /build
|
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
|
# Prepare assets
|
||||||
RUN yarn install --pure-lockfile --production && \
|
RUN yarn install --pure-lockfile --production && \
|
||||||
yarn cache clean
|
yarn cache clean
|
||||||
|
|
||||||
|
# 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
|
# Move plugin assets
|
||||||
RUN mkdir -p /assets/plugins && \
|
RUN mkdir -p /assets/plugins && \
|
||||||
cp -r /build/node_modules/admin-lte/plugins/jquery/ \
|
cp -r /build/node_modules/admin-lte/plugins/jquery/ \
|
||||||
|
@ -30,8 +33,15 @@ RUN mkdir -p /assets/plugins && \
|
||||||
/build/node_modules/admin-lte/plugins/jquery-validation/ \
|
/build/node_modules/admin-lte/plugins/jquery-validation/ \
|
||||||
/build/node_modules/admin-lte/plugins/select2/ \
|
/build/node_modules/admin-lte/plugins/select2/ \
|
||||||
/build/node_modules/jquery-tags-input/ \
|
/build/node_modules/jquery-tags-input/ \
|
||||||
/assets/plugins/
|
assets/plugins/
|
||||||
|
|
||||||
|
# Get go modules and build tool
|
||||||
|
RUN go mod download && \
|
||||||
|
go get github.com/GeertJohan/go.rice/rice
|
||||||
|
|
||||||
|
# Build
|
||||||
|
RUN rice embed-go && \
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o wg-ui .
|
||||||
|
|
||||||
# Release stage
|
# Release stage
|
||||||
FROM alpine:3.11
|
FROM alpine:3.11
|
||||||
|
@ -47,12 +57,6 @@ RUN mkdir -p db
|
||||||
|
|
||||||
# Copy binary files
|
# Copy binary files
|
||||||
COPY --from=builder --chown=wgui:wgui /build/wg-ui /app
|
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
|
RUN chmod +x wg-ui
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,13 @@ docker build -t wireguard-ui .
|
||||||
|
|
||||||
### Build binary file
|
### Build binary file
|
||||||
|
|
||||||
You can embed resources by generating Go source code
|
Prepare the assets directory
|
||||||
|
|
||||||
|
```
|
||||||
|
./prepare_assets.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can embed resources by generating Go source code
|
||||||
|
|
||||||
```
|
```
|
||||||
rice embed-go
|
rice embed-go
|
||||||
|
|
24
prepare_assets.sh
Executable file
24
prepare_assets.sh
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR=$(dirname "$0")
|
||||||
|
|
||||||
|
# install node modules
|
||||||
|
yarn install --pure-lockfile --production
|
||||||
|
|
||||||
|
# Copy admin-lte dist
|
||||||
|
mkdir -p "${DIR}/assets/dist/js" "${DIR}/assets/dist/css" && \
|
||||||
|
cp -r "${DIR}/node_modules/admin-lte/dist/js/adminlte.min.js" "${DIR}/assets/dist/js/adminlte.min.js" && \
|
||||||
|
cp -r "${DIR}/node_modules/admin-lte/dist/css/adminlte.min.css" "${DIR}/assets/dist/css/adminlte.min.css"
|
||||||
|
|
||||||
|
# Copy plugins
|
||||||
|
mkdir -p "${DIR}/assets/plugins" && \
|
||||||
|
cp -r "${DIR}/node_modules/admin-lte/plugins/jquery" \
|
||||||
|
"${DIR}/node_modules/admin-lte/plugins/fontawesome-free" \
|
||||||
|
"${DIR}/node_modules/admin-lte/plugins/bootstrap" \
|
||||||
|
"${DIR}/node_modules/admin-lte/plugins/icheck-bootstrap" \
|
||||||
|
"${DIR}/node_modules/admin-lte/plugins/toastr" \
|
||||||
|
"${DIR}/node_modules/admin-lte/plugins/jquery-validation" \
|
||||||
|
"${DIR}/node_modules/admin-lte/plugins/select2" \
|
||||||
|
"${DIR}/node_modules/jquery-tags-input" \
|
||||||
|
"${DIR}/assets/plugins/"
|
Loading…
Add table
Reference in a new issue