|
| 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"] |
0 commit comments