Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 20 additions & 15 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,35 @@ jobs:
build-and-smoke:
runs-on: ubuntu-latest
timeout-minutes: 30
services:
registry:
image: registry:3
ports: ["5000:5000"]
steps:
- uses: actions/checkout@v6.0.2
with:
ref: 'master'
ref: ${{ github.sha }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.1.0
with:
driver-opts: network=host

- name: Resolve build args
id: args
run: |
echo "url=${{ github.event.inputs.netdisco_git_url || 'https://github.com/netdisco/netdisco.git' }}" >> "$GITHUB_OUTPUT"
echo "committish=${{ github.event.inputs.committish || 'HEAD' }}" >> "$GITHUB_OUTPUT"
echo "URL=${{ github.event.inputs.netdisco_git_url || 'https://github.com/netdisco/netdisco.git' }}" >> "$GITHUB_OUTPUT"
echo "COMMITTISH=${{ github.event.inputs.committish || 'HEAD' }}" >> "$GITHUB_OUTPUT"

- name: Build images with Bake and Cache
uses: docker/bake-action@v7.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMITTISH: ${{ steps.args.outputs.committish }}
with:
files: compose.build.yaml
targets: |
netdisco-postgresql
netdisco-backend
netdisco-web
push: false
load: true
files: docker-bake.hcl
targets: standalone
push: true
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
Expand All @@ -56,11 +59,11 @@ jobs:
# netdisco user range — same failure mode as OpenShift restricted-v2
# SCC. local::lib must be able to bootstrap (i.e. /home/netdisco
# has to be writable for supplemental gid 0).
for tag in latest-backend latest-web; do
echo "::group::arbitrary UID test: netdisco/netdisco:$tag"
for tag in ${{ steps.args.outputs.committish }}-backend ${{ steps.args.outputs.committish }}-web; do
echo "::group::arbitrary UID test: localhost:5000/netdisco:$tag"
docker run --rm --user 1000050000 \
--entrypoint /home/netdisco/bin/localenv \
"netdisco/netdisco:$tag" \
"localhost:5000/netdisco:$tag" \
perl -e 'print "ok\n"'
echo "::endgroup::"
done
Expand All @@ -71,13 +74,15 @@ jobs:
sudo chown -R 901:901 netdisco

- name: Start the stack
run: docker compose up --detach
env:
COMMITTISH: ${{ steps.args.outputs.committish }}
run: docker compose -f compose.yaml -f compose.mixin.webport.yaml -f compose.mixin.localregistry.yaml --verbose up --detach

- name: Wait for netdisco-web to respond
run: |
set -e
for i in $(seq 1 90); do
code=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:5000/ || true)
code=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:3000/ || true)
echo "[$i] HTTP $code"
if [ -n "$code" ] && [ "$code" -lt 500 ] && [ "$code" -ne 000 ]; then
echo "netdisco-web responded with $code after ${i}s"
Expand Down
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,22 @@ A `/health` endpoint (suitable for container/load-balancer health probes) is ava

## Rebuilding

If you wish to build the images locally, use [this compose file](https://raw.githubusercontent.com/netdisco/netdisco-docker/refs/heads/master/compose.build.yaml) (it's not a mix-in):
If you wish to build the images locally, use a modern version of Docker which will include Docker Bake.

docker compose -f compose.build.yaml build --no-cache
COMMITTISH=HEAD docker buildx bake

Replace `HEAD` with the Git reference you wish to build from the [Netdisco repository](https://github.com/netdisco/netdisco); the
name of a branch works well. You can also add `NETDISCO_GIT_URL` to point to any other online repo, or a local folder.

This default target rebuilds only "netdisco-backend" and "netdisco-web". You can use the `standalone` target to rebuild with "netdisco-postgresql",
or the `all` target to rebuild with both "netdisco-postgresql" and "netdisco-postgresql-13".

The build images will NOT be tagged with "netdisco" prefix (they will look like "localhost:5000/netdisco:latest-web" in `docker images --tree`). To use them
with our Docker Compose files (as above), we have a [mix-in file](https://raw.githubusercontent.com/netdisco/netdisco-docker/refs/heads/master/compose.mixin.localregistry.yaml):

COMMITTISH=HEAD docker compose -f compose.yaml -f compose.mixin.localregistry.yaml up

Specifying the `COMMITTISH` will ensure you run the same images you just built (in case there are others in your Docker).

## Kubernetes / OpenShift

Expand Down
44 changes: 0 additions & 44 deletions compose.build.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions compose.mixin.localregistry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:

netdisco-postgresql:
image: localhost:5000/netdisco:${COMMITTISH:-latest}-postgresql

netdisco-postgresql-13:
image: localhost:5000/netdisco:${COMMITTISH:-latest}-postgresql-13

netdisco-db-init:
image: localhost:5000/netdisco:${COMMITTISH:-latest}-backend

netdisco-backend:
image: localhost:5000/netdisco:${COMMITTISH:-latest}-backend

netdisco-web:
image: localhost:5000/netdisco:${COMMITTISH:-latest}-web
5 changes: 5 additions & 0 deletions compose.mixin.webport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:

netdisco-web:
ports: !override
- "127.0.0.1:3000:5000"
94 changes: 94 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
variable "NETDISCO_GIT_URL" {
default = "https://github.com/netdisco/netdisco.git"
}

variable "COMMITTISH" {
default = "latest"
}

variable "BUILD_DATE" {
default = ""
}

group "default" {
targets = ["netdisco-backend","netdisco-web"]
}

group "standalone" {
targets = ["netdisco-postgresql","netdisco-backend", "netdisco-web"]
}

group "all" {
targets = ["netdisco-postgresql","netdisco-postgresql-13","netdisco-backend", "netdisco-web"]
}

target "netdisco-base" {
context = "./netdisco-base"
dockerfile = "Dockerfile"
tags = [
"localhost:5000/netdisco:${COMMITTISH}-base",
]
args = {
COMMITTISH = COMMITTISH
NETDISCO_GIT_URL = NETDISCO_GIT_URL
BUILD_DATE = BUILD_DATE
}
output = ["type=docker"]
}

target "netdisco-web" {
context = "./netdisco-web"
dockerfile = "Dockerfile"
tags = [
"localhost:5000/netdisco:${COMMITTISH}-web",
]
args = {
COMMITTISH = COMMITTISH
}
contexts = {
"localhost:5000/netdisco:${COMMITTISH}-base" = "target:netdisco-base"
}
output = ["type=docker"]
}

target "netdisco-backend" {
context = "./netdisco-backend"
dockerfile = "Dockerfile"
tags = [
"localhost:5000/netdisco:${COMMITTISH}-backend",
]
args = {
COMMITTISH = COMMITTISH
}
contexts = {
"localhost:5000/netdisco:${COMMITTISH}-base" = "target:netdisco-base"
}
output = ["type=docker"]
}

target "netdisco-postgresql" {
context = "./netdisco-postgresql"
dockerfile = "Dockerfile"
tags = [
"localhost:5000/netdisco:${COMMITTISH}-postgresql",
]
args = {
COMMITTISH = COMMITTISH
BUILD_DATE = BUILD_DATE
}
output = ["type=docker"]
}

target "netdisco-postgresql-13" {
context = "./netdisco-postgresql"
dockerfile = "Dockerfile"
tags = [
"localhost:5000/netdisco:${COMMITTISH}-postgresql-13",
]
args = {
PGVER = "13.4"
COMMITTISH = COMMITTISH
BUILD_DATE = BUILD_DATE
}
output = ["type=docker"]
}
4 changes: 2 additions & 2 deletions netdisco-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# vim: ft=Dockerfile
ARG TAG=latest
FROM localhost:5000/netdisco:${TAG}-base
ARG COMMITTISH=latest
FROM localhost:5000/netdisco:${COMMITTISH}-base

USER root

Expand Down
4 changes: 2 additions & 2 deletions netdisco-web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# vim: ft=Dockerfile
ARG TAG=latest
FROM localhost:5000/netdisco:${TAG}-base
ARG COMMITTISH=latest
FROM localhost:5000/netdisco:${COMMITTISH}-base

LABEL org.label-schema.name="netdisco-web" \
org.label-schema.description="Web Frontend for Netdisco"
Expand Down