Skip to content

Commit 7ec68ec

Browse files
committed
Build multi-arch images based on Debian
1 parent b0261e8 commit 7ec68ec

File tree

6 files changed

+455
-340
lines changed

6 files changed

+455
-340
lines changed

.github/workflows/push.yml

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ jobs:
1313
runs-on: ubuntu-latest
1414
name: Checks syntax of our code
1515
steps:
16-
- uses: actions/checkout@v2
16+
-
17+
uses: actions/checkout@v2
1718
with:
1819
# Full git history is needed to get a proper list of changed files within `super-linter`
1920
fetch-depth: 0
20-
- uses: actions/setup-python@v2
21-
- name: Lint Code Base
21+
-
22+
uses: actions/setup-python@v2
23+
-
24+
name: Lint Code Base
2225
uses: github/super-linter@v4
2326
env:
2427
DEFAULT_BRANCH: develop
@@ -35,32 +38,49 @@ jobs:
3538
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
3639
PYTHON_FLAKE8_CONFIG_FILE: .flake8
3740
PYTHON_ISORT_CONFIG_FILE: pyproject.toml
41+
3842
build:
39-
continue-on-error: ${{ matrix.docker_from == 'alpine:edge' }}
43+
continue-on-error: ${{ matrix.build_cmd != './build-latest.sh' }}
4044
strategy:
4145
matrix:
4246
build_cmd:
4347
- ./build-latest.sh
4448
- PRERELEASE=true ./build-latest.sh
4549
- ./build.sh feature
4650
- ./build.sh develop
47-
docker_from:
48-
- '' # use the default of the build script
49-
- alpine:edge
51+
platform:
52+
- linux/amd64
53+
- linux/arm64
5054
fail-fast: false
5155
runs-on: ubuntu-latest
5256
name: Builds new NetBox Docker Images
5357
steps:
54-
- id: git-checkout
58+
-
5559
name: Checkout
5660
uses: actions/checkout@v2
57-
- id: docker-build
58-
name: Build the image from '${{ matrix.docker_from }}' with '${{ matrix.build_cmd }}'
61+
-
62+
name: Get Version of NetBox Docker
63+
run: |
64+
echo "::set-output name=version::$(cat VERSION)"
65+
shell: bash
66+
-
67+
name: Set up QEMU
68+
uses: docker/setup-qemu-action@v1
69+
-
70+
id: buildx-setup
71+
name: Set up Docker Buildx
72+
uses: docker/setup-buildx-action@v1
73+
with:
74+
install: true
75+
-
76+
id: docker-build
77+
name: Build the image with '${{ matrix.build_cmd }}'
5978
run: ${{ matrix.build_cmd }}
6079
env:
61-
DOCKER_FROM: ${{ matrix.docker_from }}
6280
GH_ACTION: enable
63-
- id: docker-test
81+
BUILDX_BUILDER_NAME: ${{ steps.buildx-setup.outputs.name }}
82+
BUILDX_PLATFORMS: ${{ matrix.platform }}
83+
-
6484
name: Test the image
6585
run: IMAGE="${FINAL_DOCKER_TAG}" ./test.sh
6686
if: steps.docker-build.outputs.skipped != 'true'

.github/workflows/release.yml

Lines changed: 64 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: release
22

33
on:
4-
push:
5-
branches:
6-
- release
4+
release:
5+
types:
6+
- published
77
schedule:
88
- cron: '45 5 * * *'
99

@@ -16,68 +16,88 @@ jobs:
1616
- PRERELEASE=true ./build-latest.sh
1717
- ./build.sh feature
1818
- ./build.sh develop
19+
platform:
20+
- linux/amd64,linux/arm64
1921
fail-fast: false
2022
runs-on: ubuntu-latest
2123
name: Builds new NetBox Docker Images
2224
steps:
23-
- id: git-checkout
25+
-
2426
name: Checkout
2527
uses: actions/checkout@v2
26-
- id: docker-build
28+
-
29+
name: Get Version of NetBox Docker
30+
run: |
31+
echo "::set-output name=version::$(cat VERSION)"
32+
shell: bash
33+
-
34+
name: Set up QEMU
35+
uses: docker/setup-qemu-action@v1
36+
-
37+
id: buildx-setup
38+
name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v1
40+
with:
41+
install: true
42+
-
43+
name: Available platforms
44+
run: echo ${{ steps.buildx-setup.outputs.platforms }}
45+
-
46+
id: docker-build
2747
name: Build the image with '${{ matrix.build_cmd }}'
2848
run: ${{ matrix.build_cmd }}
2949
env:
3050
GH_ACTION: enable
31-
- id: docker-test
51+
BUILDX_BUILDER_NAME: ${{ steps.buildx-setup.outputs.name }}
52+
BUILDX_PLATFORMS: ${{ matrix.platform }}
53+
-
3254
name: Test the image
3355
run: IMAGE="${FINAL_DOCKER_TAG}" ./test.sh
3456
if: steps.docker-build.outputs.skipped != 'true'
35-
- id: registry-login
36-
name: Login to the Docker Registry
37-
run: |
38-
echo "::add-mask::$DOCKERHUB_USERNAME"
39-
echo "::add-mask::$DOCKERHUB_PASSWORD"
40-
docker login -u "$DOCKERHUB_USERNAME" --password "${DOCKERHUB_PASSWORD}" "${DOCKER_REGISTRY}"
41-
env:
42-
DOCKERHUB_USERNAME: ${{ secrets.dockerhub_username }}
43-
DOCKERHUB_PASSWORD: ${{ secrets.dockerhub_password }}
57+
-
58+
name: Login to docker.io
59+
uses: docker/login-action@v1
60+
with:
61+
registry: docker.io
62+
username: ${{ secrets.dockerhub_username }}
63+
password: ${{ secrets.dockerhub_password }}
4464
if: steps.docker-build.outputs.skipped != 'true'
45-
- id: registry-push
46-
name: Push the image
65+
-
66+
name: Push the image to docker.io
4767
run: ${{ matrix.build_cmd }} --push-only
4868
if: steps.docker-build.outputs.skipped != 'true'
49-
- id: registry-logout
50-
name: Logout of the Docker Registry
51-
run: docker logout "${DOCKER_REGISTRY}"
52-
if: steps.docker-build.outputs.skipped != 'true'
5369

54-
# Quay.io
55-
- id: quayio-docker-build
56-
name: Build the image with '${{ matrix.build_cmd }}'
57-
run: ${{ matrix.build_cmd }}
70+
# quay.io
71+
-
72+
name: Login to Quay.io
73+
uses: docker/login-action@v1
74+
with:
75+
registry: quay.io
76+
username: ${{ secrets.quayio_username }}
77+
password: ${{ secrets.quayio_password }}
78+
if: steps.docker-build.outputs.skipped != 'true'
79+
-
80+
name: Build and push the image with '${{ matrix.build_cmd }}'
81+
run: ${{ matrix.build_cmd }} --push
5882
env:
5983
DOCKER_REGISTRY: quay.io
6084
GH_ACTION: enable
61-
- id: quayio-registry-login
62-
name: Login to the Quay.io Registry
63-
run: |
64-
echo "::add-mask::$QUAYIO_USERNAME"
65-
echo "::add-mask::$QUAYIO_PASSWORD"
66-
docker login -u "$QUAYIO_USERNAME" --password "${QUAYIO_PASSWORD}" "${DOCKER_REGISTRY}"
67-
env:
68-
DOCKER_REGISTRY: quay.io
69-
QUAYIO_USERNAME: ${{ secrets.quayio_username }}
70-
QUAYIO_PASSWORD: ${{ secrets.quayio_password }}
7185
if: steps.docker-build.outputs.skipped != 'true'
72-
- id: quayio-registry-push
73-
name: Push the image
74-
run: ${{ matrix.build_cmd }} --push-only
75-
env:
76-
DOCKER_REGISTRY: quay.io
86+
87+
# ghcr.io
88+
-
89+
name: Login to GitHub Container Registry
90+
uses: docker/login-action@v1
91+
with:
92+
registry: ghcr.io
93+
username: ${{ github.repository_owner }}
94+
password: ${{ secrets.GITHUB_TOKEN }}
7795
if: steps.docker-build.outputs.skipped != 'true'
78-
- id: quayio-registry-logout
79-
name: Logout of the Docker Registry
80-
run: docker logout "${DOCKER_REGISTRY}"
96+
-
97+
name: Build and push the image with '${{ matrix.build_cmd }}'
98+
run: ${{ matrix.build_cmd }} --push
8199
env:
82-
DOCKER_REGISTRY: quay.io
100+
DOCKER_REGISTRY: ghcr.io
101+
DOCKER_ORG: netbox-community
102+
GH_ACTION: enable
83103
if: steps.docker-build.outputs.skipped != 'true'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ configuration/ldap/*
1313
!configuration/plugins.py
1414
prometheus.yml
1515
super-linter.log
16+
.buildx-cache

Dockerfile

Lines changed: 38 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,31 @@
11
ARG FROM
22
FROM ${FROM} as builder
33

4-
RUN apk add --no-cache \
5-
bash \
6-
build-base \
7-
cargo \
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
RUN apt-get update -qq \
6+
&& apt-get install \
7+
--yes -qq --no-install-recommends \
8+
build-essential \
89
ca-certificates \
9-
cmake \
10-
cyrus-sasl-dev \
11-
git \
1210
graphviz \
13-
jpeg-dev \
1411
libevent-dev \
1512
libffi-dev \
16-
libxslt-dev \
17-
make \
18-
musl-dev \
19-
openldap-dev \
20-
postgresql-dev \
21-
py3-pip \
13+
libjpeg-dev \
14+
libldap-dev \
15+
libsasl2-dev \
16+
libxslt1-dev \
17+
libxml2-dev \
18+
postgresql-13 \
2219
python3-dev \
20+
python3-pip \
21+
python3-venv \
2322
&& python3 -m venv /opt/netbox/venv \
2423
&& /opt/netbox/venv/bin/python3 -m pip install --upgrade \
2524
pip \
2625
setuptools \
2726
wheel
2827

29-
# Build libcrc32c for google-crc32c python module
30-
RUN git clone https://github.com/google/crc32c \
31-
&& cd crc32c \
32-
&& git submodule update --init --recursive \
33-
&& mkdir build \
34-
&& cd build \
35-
&& cmake \
36-
-DCMAKE_BUILD_TYPE=Release \
37-
-DCRC32C_BUILD_TESTS=no \
38-
-DCRC32C_BUILD_BENCHMARKS=no \
39-
-DBUILD_SHARED_LIBS=yes \
40-
.. \
41-
&& make all install
28+
WORKDIR /opt/netbox/
4229

4330
ARG NETBOX_PATH
4431
COPY ${NETBOX_PATH}/requirements.txt requirements-container.txt /
@@ -53,34 +40,39 @@ RUN /opt/netbox/venv/bin/pip install \
5340
ARG FROM
5441
FROM ${FROM} as main
5542

56-
RUN apk add --no-cache \
57-
bash \
43+
ENV DEBIAN_FRONTEND=noninteractive
44+
RUN . /etc/os-release \
45+
&& apt-get update -qq \
46+
&& apt-get upgrade \
47+
--yes -qq --no-install-recommends \
48+
&& apt-get install \
49+
--yes -qq --no-install-recommends \
5850
ca-certificates \
5951
curl \
60-
graphviz \
61-
libevent \
62-
libffi \
63-
libjpeg-turbo \
64-
libxslt \
6552
openssl \
66-
postgresql-libs \
67-
py3-pip \
6853
python3 \
69-
tini \
54+
python3-distutils \
55+
&& curl -sL https://nginx.org/keys/nginx_signing.key | \
56+
tee /etc/apt/trusted.gpg.d/nginx.asc \
57+
&& echo "deb https://packages.nginx.org/unit/debian/ ${VERSION_CODENAME} unit" | \
58+
tee /etc/apt/sources.list.d/unit.list \
59+
&& apt-get update -qq \
60+
&& apt-get install \
61+
--yes -qq --no-install-recommends \
7062
unit \
71-
unit-python3
63+
unit-python3.9 \
64+
tini \
65+
&& rm -rf /var/lib/apt/lists/*
7266

7367
WORKDIR /opt
7468

75-
COPY --from=builder /usr/local/lib/libcrc32c.* /usr/local/lib/
76-
COPY --from=builder /usr/local/include/crc32c /usr/local/include
77-
COPY --from=builder /usr/local/lib/cmake/Crc32c /usr/local/lib/cmake/
7869
COPY --from=builder /opt/netbox/venv /opt/netbox/venv
7970

8071
ARG NETBOX_PATH
8172
COPY ${NETBOX_PATH} /opt/netbox
8273

8374
COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py
75+
COPY docker/ldap_config.docker.py /opt/netbox/netbox/netbox/ldap_config.py
8476
COPY docker/docker-entrypoint.sh /opt/netbox/docker-entrypoint.sh
8577
COPY docker/housekeeping.sh /opt/netbox/housekeeping.sh
8678
COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh
@@ -89,36 +81,25 @@ COPY initializers/ /opt/netbox/initializers/
8981
COPY configuration/ /etc/netbox/config/
9082
COPY docker/nginx-unit.json /etc/unit/
9183

92-
WORKDIR /opt/netbox/netbox
84+
WORKDIR /opt/netbox
9385

9486
# Must set permissions for '/opt/netbox/netbox/media' directory
9587
# to g+w so that pictures can be uploaded to netbox.
9688
RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \
97-
&& chmod -R g+w media /opt/unit/ \
98-
&& cd /opt/netbox/ && /opt/netbox/venv/bin/python -m mkdocs build \
89+
&& chmod -R g+w /opt/netbox/netbox/media /opt/unit/ \
90+
&& /opt/netbox/venv/bin/python -m mkdocs build \
9991
--config-file /opt/netbox/mkdocs.yml --site-dir /opt/netbox/netbox/project-static/docs/ \
10092
&& SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
10193

102-
ENTRYPOINT [ "/sbin/tini", "--" ]
94+
WORKDIR /opt/netbox/netbox
95+
ENTRYPOINT [ "/usr/bin/tini", "--" ]
10396

10497
CMD [ "/opt/netbox/docker-entrypoint.sh", "/opt/netbox/launch-netbox.sh" ]
10598

10699
LABEL ORIGINAL_TAG="" \
107100
NETBOX_GIT_BRANCH="" \
108101
NETBOX_GIT_REF="" \
109102
NETBOX_GIT_URL="" \
110-
# See http://label-schema.org/rc1/#build-time-labels
111-
# Also https://microbadger.com/labels
112-
org.label-schema.schema-version="1.0" \
113-
org.label-schema.build-date="" \
114-
org.label-schema.name="NetBox Docker" \
115-
org.label-schema.description="A container based distribution of NetBox, the free and open IPAM and DCIM solution." \
116-
org.label-schema.vendor="The netbox-docker contributors." \
117-
org.label-schema.url="https://github.com/netbox-community/netbox-docker" \
118-
org.label-schema.usage="https://github.com/netbox-community/netbox-docker/wiki" \
119-
org.label-schema.vcs-url="https://github.com/netbox-community/netbox-docker.git" \
120-
org.label-schema.vcs-ref="" \
121-
org.label-schema.version="snapshot" \
122103
# See https://github.com/opencontainers/image-spec/blob/master/annotations.md#pre-defined-annotation-keys
123104
org.opencontainers.image.created="" \
124105
org.opencontainers.image.title="NetBox Docker" \
@@ -131,16 +112,3 @@ LABEL ORIGINAL_TAG="" \
131112
org.opencontainers.image.source="https://github.com/netbox-community/netbox-docker.git" \
132113
org.opencontainers.image.revision="" \
133114
org.opencontainers.image.version="snapshot"
134-
135-
#####
136-
## LDAP specific configuration
137-
#####
138-
139-
FROM main as ldap
140-
141-
RUN apk add --no-cache \
142-
libsasl \
143-
libldap \
144-
util-linux
145-
146-
COPY docker/ldap_config.docker.py /opt/netbox/netbox/netbox/ldap_config.py

0 commit comments

Comments
 (0)