This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
forked from palark/ovpn-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
59 lines (43 loc) · 1.62 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
# syntax=docker/dockerfile:1
# Use latest Alpine version by default
ARG ALPINE_VERSION=""
ARG ALPINE_TAG="${ALPINE_VERSION:-latest}"
ARG GO_VERSION
ARG NODE_VERSION
ARG OPENVPN_VERSION
ARG OPENVPN_PACKAGE_IDENTIFIER="r0"
ARG OPENVPN_PACKAGE_VERSION="${OPENVPN_VERSION}-${OPENVPN_PACKAGE_IDENTIFIER}"
# Frontend-builder
# ------------------------------------------------
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS frontend-builder
WORKDIR /build
# Install yarn dependencies
COPY --link frontend/.yarn/ ./.yarn/
COPY --link frontend/.yarnrc.yml frontend/package.json frontend/yarn.lock ./
RUN yarn install --immutable
# Build frontend assets
COPY --link frontend/ ./
RUN yarn run build
# Backend-builder
# ------------------------------------------------
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS backend-builder
WORKDIR /build
# Install go dependencies
COPY --link go.mod go.sum ./
RUN go mod download && go install github.com/gobuffalo/packr/v2/packr2@latest
COPY --link --from=frontend-builder /build/static/ ./frontend/static/
COPY . ./
RUN \
apk add --no-cache build-base && \
packr2 && \
env CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags '-linkmode external -extldflags -static -s -w' -o ovpn-admin && \
packr2 clean
# Web UI final image
# ------------------------------------------------
FROM alpine:${ALPINE_TAG} AS admin-webui
ARG OPENVPN_PACKAGE_VERSION
WORKDIR /app
COPY --link --from=backend-builder /build/ovpn-admin/ ./
RUN \
apk add --no-cache bash coreutils easy-rsa "openvpn=${OPENVPN_PACKAGE_VERSION}" && \
ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin