Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.5.0 #959

Merged
merged 38 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f2bb119
Update dependency django-storages to v1.13.2
renovate[bot] Dec 23, 2022
a4d9860
Merge pull request #906 from netbox-community/renovate/django-storage…
tobiasge Dec 23, 2022
89ad758
Update dependency python3-saml to v1.15.0
renovate[bot] Dec 27, 2022
73f479d
Ensure that '*' or 'localhost' is always in ALLOWED_HOSTS
tobiasge Jan 3, 2023
b6faad3
Added start_period to docker-compose example
tobiasge Jan 3, 2023
8f28206
Fix syntax of docker compose commands
kmanwar89 Jan 3, 2023
06e0815
Merge pull request #911 from netbox-community/renovate/python3-saml-1.x
tobiasge Jan 3, 2023
0c1b69d
Update docker-compose.override.yml.example
tobiasge Jan 3, 2023
7e0a8fe
Improved comment
tobiasge Jan 3, 2023
1403f52
Merge pull request #912 from tobiasge/localhost_allowed_host
tobiasge Jan 3, 2023
ff37e17
Merge pull request #913 from tobiasge/start_period_explanation
tobiasge Jan 4, 2023
015e131
Merge pull request #914 from kmanwar89/patch-1
tobiasge Jan 5, 2023
41d80d6
Prepend docker.io to image URLs
sc68cal Dec 27, 2022
bd07a7a
Add redis username parameter
christianpinger Jan 27, 2023
ff373bd
Update configuration.py
christianpinger Jan 27, 2023
3202fb9
Merge pull request #929 from christianharendt/create-redis-username
tobiasge Jan 28, 2023
f2b0375
Using GITHUB_TOKEN for API
tobiasge Jan 28, 2023
f549b93
Merge pull request #932 from tobiasge/gh-token
tobiasge Jan 28, 2023
eef45c8
Using new GITHUB_OUTPUT method
tobiasge Jan 28, 2023
250b1fb
Merge pull request #933 from tobiasge/fix-gh-warnings
tobiasge Jan 28, 2023
350747c
Merge pull request #910 from sc68cal/enforcing_shortname
tobiasge Jan 28, 2023
3071c50
implement extra LDAP user and group filters as requested in #471
timrabl Jan 27, 2023
7a9aef3
Merge pull request #931 from timrabl/fix-471
tobiasge Jan 30, 2023
6f70b88
squash commits that revert AUTH_LDAP_USER_SEARCH
timrabl Jan 27, 2023
879c700
Merge pull request #939 from timrabl/fix-931
tobiasge Feb 1, 2023
e60a746
Fixes #947: Rebuild search index when needed
tobiasge Feb 23, 2023
d3a30e1
Updated to new unit version
tobiasge Oct 7, 2022
5f8a095
Merge pull request #951 from tobiasge/new-unit
tobiasge Mar 1, 2023
ed309a1
Merge pull request #948 from tobiasge/lazy-reindex-on-start
tobiasge Mar 14, 2023
fb5bacc
Replaced curl with Skopeo for in image functions
tobiasge Mar 15, 2023
cc95a67
Fixed Github action badge
tobiasge Mar 15, 2023
f9abdf2
Merge pull request #956 from tobiasge/954-use-skopeo
tobiasge Mar 15, 2023
4bad061
Merge pull request #957 from tobiasge/fix-action-badge
tobiasge Mar 15, 2023
3e2bf7e
Don't create superuser with default credentials
tobiasge Mar 15, 2023
4ce89f9
Added check for commands to all scripts
tobiasge Mar 15, 2023
ab7e19d
Merge pull request #958 from tobiasge/954-use-skopeo
tobiasge Mar 15, 2023
480caba
Merge pull request #955 from tobiasge/953-default-admin
tobiasge Mar 15, 2023
ac8cb02
Preparation for 2.5.0
tobiasge Mar 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
fail-fast: false
env:
GH_ACTION: enable
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IMAGE_NAMES: docker.io/netboxcommunity/netbox
runs-on: ubuntu-latest
name: Builds new NetBox Docker Images
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ jobs:
name: Builds new NetBox Docker Images
env:
GH_ACTION: enable
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IMAGE_NAMES: docker.io/netboxcommunity/netbox quay.io/netboxcommunity/netbox ghcr.io/netbox-community/netbox
steps:
- id: source-checkout
name: Checkout
uses: actions/checkout@v3
- id: set-netbox-docker-version
name: Get Version of NetBox Docker
run: echo "::set-output name=version::$(cat VERSION)"
run: echo "version=$(cat VERSION)" >>"$GITHUB_OUTPUT"
shell: bash
- id: qemu-setup
name: Set up QEMU
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update -qq \
&& apt-get install \
--yes -qq --no-install-recommends \
unit=1.27.0-1~jammy \
unit-python3.10=1.27.0-1~jammy \
unit=1.29.1-1~jammy \
unit-python3.10=1.29.1-1~jammy \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /opt/netbox/venv /opt/netbox/venv
Expand All @@ -94,7 +94,7 @@ RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \
--config-file /opt/netbox/mkdocs.yml --site-dir /opt/netbox/netbox/project-static/docs/ \
&& SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input

ENV LANG=C.UTF-8 PATH=/opt/netbox/venv/bin:$PATH
ENV LANG=C.utf8 PATH=/opt/netbox/venv/bin:$PATH
ENTRYPOINT [ "/usr/bin/tini", "--" ]

CMD [ "/opt/netbox/docker-entrypoint.sh", "/opt/netbox/launch-netbox.sh" ]
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/netbox-community/netbox-docker)][github-release]
[![GitHub stars](https://img.shields.io/github/stars/netbox-community/netbox-docker)][github-stargazers]
![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed-raw/netbox-community/netbox-docker)
![Github release workflow](https://img.shields.io/github/workflow/status/netbox-community/netbox-docker/release)
![Github release workflow](https://img.shields.io/github/actions/workflow/status/netbox-community/netbox-docker/release.yml?branch=release)
![Docker Pulls](https://img.shields.io/docker/pulls/netboxcommunity/netbox)
[![GitHub license](https://img.shields.io/github/license/netbox-community/netbox-docker)][netbox-docker-license]

Expand Down Expand Up @@ -40,19 +40,21 @@ services:
ports:
- 8000:8080
EOF
docker-compose pull
docker-compose up
docker compose pull
docker compose up
```

The whole application will be available after a few minutes.
Open the URL `http://0.0.0.0:8000/` in a web-browser.
You should see the NetBox homepage.
In the top-right corner you can login.
The default credentials are:

* Username: **admin**
* Password: **admin**
* API Token: **0123456789abcdef0123456789abcdef01234567**
To create the first admin user run this command:

```bash
docker compose exec netbox /opt/netbox/netbox/manage.py createsuperuser
```

If you need to restart Netbox from an empty database often, you can also set the `SUPERUSER_*` variables in your `docker-compose.override.yml` as shown in the example.

[wiki-getting-started]: https://github.com/netbox-community/netbox-docker/wiki/Getting-Started

Expand Down Expand Up @@ -123,7 +125,7 @@ This project relies only on _Docker_ and _docker-compose_ meeting these requirem
* The _containerd version_ must be at least `1.5.6`.
* The _docker-compose version_ must be at least `1.28.0`.

To check the version installed on your system run `docker --version` and `docker-compose --version`.
To check the version installed on your system run `docker --version` and `docker compose version`.

## Updating

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.0
2.5.0
9 changes: 9 additions & 0 deletions build-functions/check-commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

NEEDED_COMMANDS="curl jq docker skopeo"
for c in $NEEDED_COMMANDS; do
if ! command -v "$c" &>/dev/null; then
echo "⚠️ '$c' is not installed. Can't proceed with build."
exit 1
fi
done
71 changes: 3 additions & 68 deletions build-functions/get-public-image-config.sh
Original file line number Diff line number Diff line change
@@ -1,82 +1,17 @@
#!/bin/bash
# Retrieves image configuration from public images in DockerHub
# Functions from https://gist.github.com/cirocosta/17ea17be7ac11594cb0f290b0a3ac0d1
# Optimised for our use case

get_image_label() {
local label=$1
local image=$2
local tag=$3
local token
token=$(_get_token "$image")
local digest
digest=$(_get_digest "$image" "$tag" "$token")
local retval="null"
if [ "$digest" != "null" ]; then
retval=$(_get_image_configuration "$image" "$token" "$digest" "$label")
fi
echo "$retval"
skopeo inspect "docker://$image" | jq -r ".Labels[\"$label\"]"
}

get_image_layers() {
local image=$1
local tag=$2
local token
token=$(_get_token "$image")
_get_layers "$image" "$tag" "$token"
skopeo inspect "docker://$image" | jq -r ".Layers"
}

get_image_last_layer() {
local image=$1
local tag=$2
local token
token=$(_get_token "$image")
local layers
mapfile -t layers < <(_get_layers "$image" "$tag" "$token")
echo "${layers[-1]}"
}

_get_image_configuration() {
local image=$1
local token=$2
local digest=$3
local label=$4
curl \
--silent \
--location \
--header "Authorization: Bearer $token" \
"https://registry-1.docker.io/v2/$image/blobs/$digest" |
jq -r ".config.Labels.\"$label\""
}

_get_token() {
local image=$1
curl \
--silent \
"https://auth.docker.io/token?scope=repository:$image:pull&service=registry.docker.io" |
jq -r '.token'
}

_get_digest() {
local image=$1
local tag=$2
local token=$3
curl \
--silent \
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
--header "Authorization: Bearer $token" \
"https://registry-1.docker.io/v2/$image/manifests/$tag" |
jq -r '.config.digest'
}

_get_layers() {
local image=$1
local tag=$2
local token=$3
curl \
--silent \
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
--header "Authorization: Bearer $token" \
"https://registry-1.docker.io/v2/$image/manifests/$tag" |
jq -r '.layers[].digest'
skopeo inspect "docker://$image" | jq -r ".Layers | last"
}
11 changes: 11 additions & 0 deletions build-functions/gh-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@ gh_env() {
echo "${@}" >>"${GITHUB_ENV}"
fi
}

###
# Prints the output to the file defined in ${GITHUB_OUTPUT}.
# Only executes if ${GH_ACTION} is defined.
# Example Usage: gh_env "FOO_VAR=bar_value"
###
gh_out() {
if [ -n "${GH_ACTION}" ]; then
echo "${@}" >>"$GITHUB_OUTPUT"
fi
}
50 changes: 22 additions & 28 deletions build-latest.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
#!/bin/bash
# Builds the latest released version

# Check if we have everything needed for the build
source ./build-functions/check-commands.sh

source ./build-functions/gh-functions.sh

echo "▶️ $0 $*"

###
# Check for the jq library needed for parsing JSON
###
if ! command -v jq; then
echo "⚠️ jq command missing from \$PATH!"
exit 1
fi
CURL_ARGS=(
--silent
)

###
# Checking for the presence of GITHUB_OAUTH_CLIENT_ID
# and GITHUB_OAUTH_CLIENT_SECRET
# Checking for the presence of GITHUB_TOKEN
###
if [ -n "${GITHUB_OAUTH_CLIENT_ID}" ] && [ -n "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then
if [ -n "${GITHUB_TOKEN}" ]; then
echo "🗝 Performing authenticated Github API calls."
GITHUB_OAUTH_PARAMS="client_id=${GITHUB_OAUTH_CLIENT_ID}&client_secret=${GITHUB_OAUTH_CLIENT_SECRET}"
CURL_ARGS+=(
--header "Authorization: Bearer ${GITHUB_TOKEN}"
)
else
echo "🕶 Performing unauthenticated Github API calls. This might result in lower Github rate limits!"
GITHUB_OAUTH_PARAMS=""
fi

###
Expand All @@ -42,31 +43,27 @@ fi
###
ORIGINAL_GITHUB_REPO="netbox-community/netbox"
GITHUB_REPO="${GITHUB_REPO-$ORIGINAL_GITHUB_REPO}"
URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/releases?${GITHUB_OAUTH_PARAMS}"
URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/releases"

# Composing the JQ commans to extract the most recent version number
JQ_LATEST="group_by(.prerelease) | .[] | sort_by(.published_at) | reverse | .[0] | select(.prerelease==${PRERELEASE-false}) | .tag_name"

CURL="curl -sS"
CURL="curl"

# Querying the Github API to fetch the most recent version number
VERSION=$($CURL "${URL_RELEASES}" | jq -r "${JQ_LATEST}")
VERSION=$($CURL "${CURL_ARGS[@]}" "${URL_RELEASES}" | jq -r "${JQ_LATEST}" 2>/dev/null)

###
# Check if the prerelease version is actually higher than stable version
###
if [ "${PRERELEASE}" == "true" ]; then
JQ_STABLE="group_by(.prerelease) | .[] | sort_by(.published_at) | reverse | .[0] | select(.prerelease==false) | .tag_name"
STABLE_VERSION=$($CURL "${URL_RELEASES}" | jq -r "${JQ_STABLE}")
STABLE_VERSION=$($CURL "${CURL_ARGS[@]}" "${URL_RELEASES}" | jq -r "${JQ_STABLE}" 2>/dev/null)

# shellcheck disable=SC2003
MAJOR_STABLE=$(expr match "${STABLE_VERSION}" 'v\([0-9]\+\)')
# shellcheck disable=SC2003
MINOR_STABLE=$(expr match "${STABLE_VERSION}" 'v[0-9]\+\.\([0-9]\+\)')
# shellcheck disable=SC2003
MAJOR_UNSTABLE=$(expr match "${VERSION}" 'v\([0-9]\+\)')
# shellcheck disable=SC2003
MINOR_UNSTABLE=$(expr match "${VERSION}" 'v[0-9]\+\.\([0-9]\+\)')
MAJOR_STABLE=$(expr "${STABLE_VERSION}" : 'v\([0-9]\+\)')
MINOR_STABLE=$(expr "${STABLE_VERSION}" : 'v[0-9]\+\.\([0-9]\+\)')
MAJOR_UNSTABLE=$(expr "${VERSION}" : 'v\([0-9]\+\)')
MINOR_UNSTABLE=$(expr "${VERSION}" : 'v[0-9]\+\.\([0-9]\+\)')

if {
[ "${MAJOR_STABLE}" -eq "${MAJOR_UNSTABLE}" ] &&
Expand All @@ -75,10 +72,7 @@ if [ "${PRERELEASE}" == "true" ]; then

echo "❎ Latest unstable version '${VERSION}' is not higher than the latest stable version '$STABLE_VERSION'."
if [ -z "$DEBUG" ]; then
if [ -n "${GH_ACTION}" ]; then
echo "::set-output name=skipped::true"
fi

gh_out "skipped=true"
exit 0
else
echo "⚠️ Would exit here with code '0', but DEBUG is enabled."
Expand Down
35 changes: 15 additions & 20 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ END_OF_HELP
fi
fi

# Check if we have everything needed for the build
source ./build-functions/check-commands.sh

source ./build-functions/gh-functions.sh

IMAGE_NAMES="${IMAGE_NAMES-docker.io/netboxcommunity/netbox}"
Expand Down Expand Up @@ -170,7 +173,7 @@ if [ "${2}" != "--push-only" ] && [ -z "${SKIP_GIT}" ]; then
REMOTE_EXISTS=$(git ls-remote --heads --tags "${URL}" "${NETBOX_BRANCH}" | wc -l)
if [ "${REMOTE_EXISTS}" == "0" ]; then
echo "❌ Remote branch '${NETBOX_BRANCH}' not found in '${URL}'; Nothing to do"
gh_echo "::set-output name=skipped::true"
gh_out "skipped=true"
exit 0
fi
echo "🌐 Checking out '${NETBOX_BRANCH}' of NetBox from the url '${URL}' into '${NETBOX_PATH}'"
Expand Down Expand Up @@ -215,7 +218,7 @@ fi
# Determining the value for DOCKER_FROM
###
if [ -z "$DOCKER_FROM" ]; then
DOCKER_FROM="ubuntu:22.04"
DOCKER_FROM="docker.io/ubuntu:22.04"
fi

###
Expand Down Expand Up @@ -300,6 +303,7 @@ if [ -n "${TARGET_DOCKER_SHORT_TAG}" ]; then
done
fi

FINAL_DOCKER_TAG="${IMAGE_NAME_TAGS[0]}"
gh_env "FINAL_DOCKER_TAG=${IMAGE_NAME_TAGS[0]}"

###
Expand All @@ -316,23 +320,17 @@ if [ -z "${GH_ACTION}" ]; then
# Asuming non Github builds should always proceed
SHOULD_BUILD="true"
BUILD_REASON="${BUILD_REASON} interactive"
elif [[ "${IMAGE_NAME_TAGS[0]}" = docker.io* ]]; then
else
source ./build-functions/get-public-image-config.sh
IFS=':' read -ra DOCKER_FROM_SPLIT <<<"${DOCKER_FROM}"
if ! [[ ${DOCKER_FROM_SPLIT[0]} =~ .*/.* ]]; then
# Need to use "library/..." for images the have no two part name
DOCKER_FROM_SPLIT[0]="library/${DOCKER_FROM_SPLIT[0]}"
fi
IFS='/' read -ra ORG_REPO <<<"${IMAGE_NAMES[0]}"
echo "Checking labels for '${ORG_REPO[1]}' and '${ORG_REPO[2]}'"
BASE_LAST_LAYER=$(get_image_last_layer "${DOCKER_FROM_SPLIT[0]}" "${DOCKER_FROM_SPLIT[1]}")
mapfile -t IMAGES_LAYERS_OLD < <(get_image_layers "${ORG_REPO[1]}"/"${ORG_REPO[2]}" "${TAG}")
NETBOX_GIT_REF_OLD=$(get_image_label netbox.git-ref "${ORG_REPO[1]}"/"${ORG_REPO[2]}" "${TAG}")
GIT_REF_OLD=$(get_image_label org.opencontainers.image.revision "${ORG_REPO[1]}"/"${ORG_REPO[2]}" "${TAG}")
echo "Checking labels for '${FINAL_DOCKER_TAG}'"
BASE_LAST_LAYER=$(get_image_last_layer "${DOCKER_FROM}")
mapfile -t IMAGES_LAYERS_OLD < <(get_image_layers "${FINAL_DOCKER_TAG}")
NETBOX_GIT_REF_OLD=$(get_image_label netbox.git-ref "${FINAL_DOCKER_TAG}")
GIT_REF_OLD=$(get_image_label org.opencontainers.image.revision "${FINAL_DOCKER_TAG}")

if ! printf '%s\n' "${IMAGES_LAYERS_OLD[@]}" | grep -q -P "^${BASE_LAST_LAYER}\$"; then
SHOULD_BUILD="true"
BUILD_REASON="${BUILD_REASON} debian"
BUILD_REASON="${BUILD_REASON} ubuntu"
fi
if [ "${NETBOX_GIT_REF}" != "${NETBOX_GIT_REF_OLD}" ]; then
SHOULD_BUILD="true"
Expand All @@ -342,17 +340,14 @@ elif [[ "${IMAGE_NAME_TAGS[0]}" = docker.io* ]]; then
SHOULD_BUILD="true"
BUILD_REASON="${BUILD_REASON} netbox-docker"
fi
else
SHOULD_BUILD="true"
BUILD_REASON="${BUILD_REASON} no-check"
fi

if [ "${SHOULD_BUILD}" != "true" ]; then
echo "Build skipped because sources didn't change"
echo "::set-output name=skipped::true"
gh_out "skipped=true"
exit 0 # Nothing to do -> exit
else
gh_echo "::set-output name=skipped::false"
gh_out "skipped=false"
fi
gh_echo "::endgroup::"

Expand Down
Loading