1
0
Fork 0
mirror of synced 2024-12-18 04:29:46 -05:00

Multi-platform build (#234)

* add multi-platform build
This commit is contained in:
Sprait 2023-09-04 19:24:13 +03:00 committed by GitHub
parent dbc48ef3f1
commit 4981dcb919
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 32 deletions

View file

@ -12,19 +12,24 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Push openvpn image to Docker Hub - name: Push openvpn image to Docker Hub
uses: docker/build-push-action@v1 uses: docker/build-push-action@v4
with: with:
username: ${{ secrets.DOCKER_USER }} tags: flant/ovpn-admin:openvpn-latest
password: ${{ secrets.DOCKER_PASS }} platforms: linux/amd64,linux/arm64,linux/arm,linux/386
repository: flant/ovpn-admin file: Dockerfile.openvpn
tags: openvpn-latest push: true
dockerfile: Dockerfile.openvpn
- name: Push ovpn-admin image to Docker Hub - name: Push ovpn-admin image to Docker Hub
uses: docker/build-push-action@v1 uses: docker/build-push-action@v4
with: with:
username: ${{ secrets.DOCKER_USER }} tags: flant/ovpn-admin:latest
password: ${{ secrets.DOCKER_PASS }} platforms: linux/amd64,linux/arm64,linux/arm,linux/386
repository: flant/ovpn-admin file: Dockerfile
tags: latest push: true
dockerfile: Dockerfile

View file

@ -16,19 +16,24 @@ jobs:
- name: Get the version - name: Get the version
id: get_version id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Push openvpn image to Docker Hub - name: Push openvpn image to Docker Hub
uses: docker/build-push-action@v1 uses: docker/build-push-action@v4
with: with:
username: ${{ secrets.DOCKER_USER }} tags: flant/ovpn-admin:openvpn-${{ steps.get_version.outputs.VERSION }}
password: ${{ secrets.DOCKER_PASS }} platforms: linux/amd64,linux/arm64,linux/arm,linux/386
repository: flant/ovpn-admin file: Dockerfile.openvpn
tags: openvpn-${{ steps.get_version.outputs.VERSION }} push: true
dockerfile: Dockerfile.openvpn
- name: Push ovpn-admin image to Docker Hub - name: Push ovpn-admin image to Docker Hub
uses: docker/build-push-action@v1 uses: docker/build-push-action@v4
with: with:
username: ${{ secrets.DOCKER_USER }} tags: flant/ovpn-admin:${{ steps.get_version.outputs.VERSION }}
password: ${{ secrets.DOCKER_PASS }} platforms: linux/amd64,linux/arm64,linux/arm,linux/386
repository: flant/ovpn-admin file: Dockerfile
tags: ${{ steps.get_version.outputs.VERSION }} push: true
dockerfile: Dockerfile

View file

@ -1,17 +1,20 @@
FROM node:16-alpine3.15 AS frontend-builder FROM node:16-alpine3.15 AS frontend-builder
COPY frontend/ /app COPY frontend/ /app
RUN cd /app && npm install && npm run build RUN apk add --update python3 make g++ && cd /app && npm install && npm run build
FROM golang:1.17.3-buster AS backend-builder FROM golang:1.17.3-buster AS backend-builder
RUN go install github.com/gobuffalo/packr/v2/packr2@latest RUN go install github.com/gobuffalo/packr/v2/packr2@latest
COPY --from=frontend-builder /app/static /app/frontend/static COPY --from=frontend-builder /app/static /app/frontend/static
COPY . /app COPY . /app
RUN cd /app && 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 ARG TARGETARCH
RUN cd /app && packr2 && env CGO_ENABLED=1 GOOS=linux GOARCH=${TARGETARCH} go build -a -tags netgo -ldflags '-linkmode external -extldflags -static -s -w' -o ovpn-admin && packr2 clean
FROM alpine:3.16 FROM alpine:3.16
WORKDIR /app WORKDIR /app
COPY --from=backend-builder /app/ovpn-admin /app COPY --from=backend-builder /app/ovpn-admin /app
ARG TARGETARCH
RUN apk add --update bash easy-rsa openssl openvpn coreutils && \ RUN apk add --update bash easy-rsa openssl openvpn coreutils && \
ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin && \ ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin && \
wget https://github.com/pashcovich/openvpn-user/releases/download/v1.0.4/openvpn-user-linux-amd64.tar.gz -O - | tar xz -C /usr/local/bin && \ wget https://github.com/pashcovich/openvpn-user/releases/download/v1.0.4/openvpn-user-linux-${TARGETARCH}.tar.gz -O - | tar xz -C /usr/local/bin && \
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/* rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/*
RUN if [ -f "/usr/local/bin/openvpn-user-${TARGETARCH}" ]; then ln -s /usr/local/bin/openvpn-user-${TARGETARCH} /usr/local/bin/openvpn-user; fi

View file

@ -1,7 +1,9 @@
FROM alpine:3.16 FROM alpine:3.16
ARG TARGETARCH
RUN apk add --update bash openvpn easy-rsa iptables && \ RUN apk add --update bash openvpn easy-rsa iptables && \
ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin && \ ln -s /usr/share/easy-rsa/easyrsa /usr/local/bin && \
wget https://github.com/pashcovich/openvpn-user/releases/download/v1.0.4/openvpn-user-linux-amd64.tar.gz -O - | tar xz -C /usr/local/bin && \ wget https://github.com/pashcovich/openvpn-user/releases/download/v1.0.4/openvpn-user-linux-${TARGETARCH}.tar.gz -O - | tar xz -C /usr/local/bin && \
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/* rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/*
RUN if [ -f "/usr/local/bin/openvpn-user-${TARGETARCH}" ]; then ln -s /usr/local/bin/openvpn-user-${TARGETARCH} /usr/local/bin/openvpn-user; fi
COPY setup/ /etc/openvpn/setup COPY setup/ /etc/openvpn/setup
RUN chmod +x /etc/openvpn/setup/configure.sh RUN chmod +x /etc/openvpn/setup/configure.sh

View file

@ -94,9 +94,6 @@ var logFormats = map[string]log.Formatter{
"json": &log.JSONFormatter{}, "json": &log.JSONFormatter{},
} }
var (
)
var ( var (
ovpnServerCertExpire = prometheus.NewGauge(prometheus.GaugeOpts{ ovpnServerCertExpire = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "ovpn_server_cert_expire", Name: "ovpn_server_cert_expire",