Skip to content

Commit 9870c44

Browse files
authored
Merge pull request #486 from rizlas/development
feat: GA build and push docker image
2 parents 499862a + 577caeb commit 9870c44

2 files changed

Lines changed: 88 additions & 2 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build netbox-sync docker image
2+
3+
on:
4+
push:
5+
tags:
6+
- v[0-9]+.[0-9]+.[0-9]+
7+
branches:
8+
- development
9+
paths:
10+
- module/**
11+
- netbox-sync.py
12+
- requirements.txt
13+
workflow_dispatch:
14+
15+
jobs:
16+
build-and-push:
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v6
26+
27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@v3
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Lower case docker image name
34+
id: docker_image
35+
uses: ASzc/change-string-case-action@v6
36+
with:
37+
string: ${{ github.repository }}
38+
39+
- name: Log in to GitHub Container Registry
40+
uses: docker/login-action@v3
41+
with:
42+
registry: ghcr.io
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Docker meta GitHub Container Registry
47+
id: meta
48+
uses: docker/metadata-action@v5
49+
with:
50+
images: ghcr.io/${{ steps.docker_image.outputs.lowercase }}
51+
tags: |
52+
type=semver,pattern={{version}}
53+
type=ref,event=branch
54+
55+
- name: Build and push with tags - ${{ steps.meta.outputs.tags }}
56+
uses: docker/build-push-action@v6
57+
with:
58+
context: .
59+
push: true
60+
platforms: linux/amd64,linux/arm64
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
64+
- name: Log in to Docker Hub
65+
uses: docker/login-action@v3
66+
with:
67+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
68+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
69+
70+
- name: Docker hub meta
71+
id: meta_dhub
72+
uses: docker/metadata-action@v5
73+
with:
74+
images: docker.io/bbricardo/${{ steps.docker_image.outputs.lowercase }}
75+
tags: |
76+
type=semver,pattern={{version}}
77+
type=ref,event=branch
78+
79+
- name: Build and push with tags - ${{ steps.meta_dhub.outputs.tags }}
80+
uses: docker/build-push-action@v6
81+
with:
82+
context: .
83+
push: true
84+
platforms: linux/amd64,linux/arm64
85+
tags: ${{ steps.meta_dhub.outputs.tags }}
86+
labels: ${{ steps.meta_dhub.outputs.labels }}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11-slim-bookworm AS builder
1+
FROM python:3.11-slim AS builder
22

33
COPY requirements.txt .
44

@@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends git && \
1313
$VENV/bin/pip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git && \
1414
find $VENV -type d -name "__pycache__" -print0 | xargs -0 -n1 rm -rf
1515

16-
FROM python:3.11-slim-bookworm AS netbox-sync
16+
FROM python:3.11-slim AS netbox-sync
1717

1818
ARG VENV=/opt/netbox-sync/venv
1919

0 commit comments

Comments
 (0)