Fix build

Signed-off-by: maksim.nabokikh <max.nabokih@gmail.com>
This commit is contained in:
maksim.nabokikh 2025-03-03 14:58:34 +01:00
parent 696bf332c6
commit 2dcdfc395b
5 changed files with 58 additions and 25 deletions

View File

@ -12,7 +12,7 @@ updates:
schedule: schedule:
interval: "weekly" interval: "weekly"
# Dependencies listed in Dockerfile # Dependencies listed in Dockerfile.ovpn-admin
- package-ecosystem: "docker" - package-ecosystem: "docker"
directory: "/" directory: "/"
schedule: schedule:

View File

@ -24,12 +24,12 @@ jobs:
with: with:
tags: flant/ovpn-admin:openvpn-latest tags: flant/ovpn-admin:openvpn-latest
platforms: linux/amd64,linux/arm64,linux/arm platforms: linux/amd64,linux/arm64,linux/arm
file: Dockerfile.openvpn file: Dockerfile.ovpn-admin
push: true push: true
- name: Push ovpn-admin image to Docker Hub - name: Push ovpn-admin image to Docker Hub
uses: docker/build-push-action@v4 uses: docker/build-push-action@v4
with: with:
tags: flant/ovpn-admin:latest tags: flant/ovpn-admin:latest
platforms: linux/amd64,linux/arm64,linux/arm platforms: linux/amd64,linux/arm64,linux/arm
file: Dockerfile file: Dockerfile.openvpn
push: true push: true

View File

@ -1,4 +1,4 @@
name: Build and publish tags to Docker Hub (tags only) name: Build and publish tags to ghcr.io
on: on:
push: push:
tags: tags:
@ -8,32 +8,65 @@ jobs:
build: build:
name: build images for tag name: build images for tag
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./Dockerfile.ovpn-admin
image: ovpn-admin
- dockerfile: ./Dockerfile.openvpn
image: openvpn
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- 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 - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2 # Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3.3.0
with: with:
username: ${{ secrets.DOCKER_USER }} registry: ${{ env.REGISTRY }}
password: ${{ secrets.DOCKER_PASS }} username: ${{ secrets.DECKHOUSE_REGISTRY_USER }}
- name: Push openvpn image to Docker Hub password: ${{ secrets.DECKHOUSE_REGISTRY_PASSWORD }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5.6.1
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.image }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v6.10.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TAG=${{ github.ref_name }}
- name: Push Image
uses: docker/build-push-action@v4 uses: docker/build-push-action@v4
with: with:
tags: flant/ovpn-admin:openvpn-${{ steps.get_version.outputs.VERSION }} context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TAG=${{ github.ref_name }}
platforms: linux/amd64,linux/arm64,linux/arm platforms: linux/amd64,linux/arm64,linux/arm
file: Dockerfile.openvpn file: ${{ matrix.dockerfile }}
push: true
- name: Push ovpn-admin image to Docker Hub
uses: docker/build-push-action@v4
with:
tags: flant/ovpn-admin:${{ steps.get_version.outputs.VERSION }}
platforms: linux/amd64,linux/arm64,linux/arm
file: Dockerfile
push: true

View File

@ -1,11 +1,11 @@
FROM node:16-alpine3.15 AS frontend-builder FROM node:16-alpine3.15 AS frontend-builder
COPY frontend/ /app COPY ../frontend /app
RUN apk add --update python3 make g++ && 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
ARG TARGETARCH 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 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

View File

@ -1,10 +1,10 @@
project: ovpn-admin project: ovpn-admin
configVersion: 1 configVersion: 1
--- ---
image: ovpn-admin image: ovpn-admin
dockerfile: Dockerfile dockerfile: Dockerfile.ovpn-admin
context: .
--- ---
image: openvpn image: openvpn
dockerfile: Dockerfile.openvpn dockerfile: Dockerfile.openvpn
context: .