From 5ae01708eaace19b8c6b4b87efac8babf04c4a31 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Sun, 3 Nov 2024 14:43:35 +0200 Subject: [PATCH 1/4] feature: ubuntu 24.04 and node22 for docker --- docker/Dockerfile_base | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile_base b/docker/Dockerfile_base index 3e31f4744..ae4330971 100644 --- a/docker/Dockerfile_base +++ b/docker/Dockerfile_base @@ -1,12 +1,13 @@ -FROM ubuntu:22.04 +FROM ubuntu:24.04 +RUN userdel -r ubuntu RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install git python3 python2 build-essential avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan libavahi-compat-libdnssd-dev sysstat procps nano curl libcap2-bin sudo dbus bluez\ - && groupadd -r docker -g 998 && groupadd -r i2c -g 997 && groupadd -r spi -g 999 && usermod -a -G dialout,i2c,spi,netdev,docker node +RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install git python3 build-essential avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan libavahi-compat-libdnssd-dev sysstat procps nano curl libcap2-bin sudo dbus bluez\ + && groupadd -r docker -g 991 && groupadd -r i2c -g 990 && groupadd -r spi -g 989 && usermod -a -G dialout,i2c,spi,netdev,docker node -RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ +RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ && DEBIAN_FRONTEND=noninteractive apt-get -y install nodejs \ && npm config rm proxy \ && npm config rm https-proxy \ From 99914522001e58230ec4dcc165662ed10e20cda2 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Sun, 10 Nov 2024 22:48:48 +0200 Subject: [PATCH 2/4] added ununtu 24.04 and node22.x build pipelines --- .github/workflows/build-base-image-test.yml | 66 +++++++++++++++ .github/workflows/build-docker-test.yml | 89 +++++++++++++++++++++ docker/Dockerfile_base | 11 ++- docker/Dockerfile_base_test | 27 +++++++ docker/Dockerfile_rel_test | 25 ++++++ docker/Dockerfile_test | 41 ++++++++++ docker/startup_test.sh | 6 ++ 7 files changed, 259 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build-base-image-test.yml create mode 100644 .github/workflows/build-docker-test.yml create mode 100644 docker/Dockerfile_base_test create mode 100644 docker/Dockerfile_rel_test create mode 100644 docker/Dockerfile_test create mode 100644 docker/startup_test.sh diff --git a/.github/workflows/build-base-image-test.yml b/.github/workflows/build-base-image-test.yml new file mode 100644 index 000000000..aad0029ba --- /dev/null +++ b/.github/workflows/build-base-image-test.yml @@ -0,0 +1,66 @@ +name: Build Docker base test image + +on: + schedule: + - cron: "0 0 * * 1" + workflow_dispatch: + +jobs: + build_docker_base_images: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: signalkci + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GHCR_PAT }} # Personal access tokens (classic) with a scope of "write:packages" is needed to release ghcr.io package registry. + + - name: Build baseimages and push with test tag + uses: docker/build-push-action@v5 + with: + file: ./docker/Dockerfile_base_test + platforms: linux/amd64,linux/arm/v7,linux/arm64 + push: true + tags: | + signalk/signalk-server-base:test_ + ghcr.io/signalk/signalk-server-base:test_ + + - name: Modify Dockerfile_rel for testing + run: | + sed -i 's/:latest/:test_/g' ./docker/Dockerfile_rel_test + + - name: Build Signal K test dockers + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/Dockerfile_rel_test + platforms: linux/amd64,linux/arm/v7,linux/arm64 + build-args: | + TAG=latest_test + + - name: Push baseimages to registries with latest tag + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/Dockerfile_base_test + platforms: linux/amd64,linux/arm/v7,linux/arm64 + push: true + tags: | + signalk/signalk-server-base:latest_test + ghcr.io/signalk/signalk-server-base:latest_test \ No newline at end of file diff --git a/.github/workflows/build-docker-test.yml b/.github/workflows/build-docker-test.yml new file mode 100644 index 000000000..416f46402 --- /dev/null +++ b/.github/workflows/build-docker-test.yml @@ -0,0 +1,89 @@ +name: Build Docker development test container + +on: + push: + branches: + - master + - "build-docker" + - metadata-editing + tags: + - '*' + - '!v*' + workflow_dispatch: + +jobs: + signalk-server_npm_files: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Node setup + uses: actions/setup-node@v4 + with: + node-version: '22.x' + + - name: Build npm files locally and upload artifacts + run: | + npm cache clean -f + npm install npm@latest -g + npm install --package-lock-only + npm ci && npm cache clean --force + npm run build --workspaces --if-present + cd packages/server-admin-ui + npm pack && mv *.tgz ../../ + cd ../server-api + npm pack && mv *.tgz ../../ + cd ../streams + npm pack && mv *.tgz ../../ + cd ../resources-provider-plugin + npm pack && mv *.tgz ../../ + cd ../.. + jq '.workspaces=[]' package.json > _package.json && mv _package.json package.json + npm i --save *.tgz + npm run build + npm pack + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + retention-days: 1 + name: packed-modules + path: | + *.tgz + + build_docker_images: + runs-on: ubuntu-latest + needs: [signalk-server_npm_files] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: signalkci + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GHCR_PAT }} # Personal access tokens (classic) with a scope of "write:packages" is needed to release ghcr.io package registry. + - uses: actions/download-artifact@v4 + with: + name: packed-modules + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/Dockerfile_test + platforms: linux/amd64,linux/arm/v7,linux/arm64 + push: true + tags: | + signalk/signalk-server:latest_test + ghcr.io/signalk/signalk-server:latest_test diff --git a/docker/Dockerfile_base b/docker/Dockerfile_base index ae4330971..c7dadef6a 100644 --- a/docker/Dockerfile_base +++ b/docker/Dockerfile_base @@ -1,13 +1,12 @@ -FROM ubuntu:24.04 +FROM ubuntu:22.04 -RUN userdel -r ubuntu RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node -RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install git python3 build-essential avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan libavahi-compat-libdnssd-dev sysstat procps nano curl libcap2-bin sudo dbus bluez\ - && groupadd -r docker -g 991 && groupadd -r i2c -g 990 && groupadd -r spi -g 989 && usermod -a -G dialout,i2c,spi,netdev,docker node +RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install git python3 python2 build-essential avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan libavahi-compat-libdnssd-dev sysstat procps nano curl libcap2-bin sudo dbus bluez\ + && groupadd -r docker -g 998 && groupadd -r i2c -g 997 && groupadd -r spi -g 999 && usermod -a -G dialout,i2c,spi,netdev,docker node -RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ && DEBIAN_FRONTEND=noninteractive apt-get -y install nodejs \ && npm config rm proxy \ && npm config rm https-proxy \ @@ -24,4 +23,4 @@ RUN mkdir -p /var/run/dbus/ \ && chmod -R 777 /var/run/dbus/ \ && mkdir -p /var/run/avahi-daemon/ \ && chmod -R 777 /var/run/avahi-daemon/ \ - && chown -R avahi:avahi /var/run/avahi-daemon/ + && chown -R avahi:avahi /var/run/avahi-daemon/ \ No newline at end of file diff --git a/docker/Dockerfile_base_test b/docker/Dockerfile_base_test new file mode 100644 index 000000000..ae4330971 --- /dev/null +++ b/docker/Dockerfile_base_test @@ -0,0 +1,27 @@ +FROM ubuntu:24.04 + +RUN userdel -r ubuntu +RUN groupadd --gid 1000 node \ + && useradd --uid 1000 --gid node --shell /bin/bash --create-home node + +RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install git python3 build-essential avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan libavahi-compat-libdnssd-dev sysstat procps nano curl libcap2-bin sudo dbus bluez\ + && groupadd -r docker -g 991 && groupadd -r i2c -g 990 && groupadd -r spi -g 989 && usermod -a -G dialout,i2c,spi,netdev,docker node + +RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ + && DEBIAN_FRONTEND=noninteractive apt-get -y install nodejs \ + && npm config rm proxy \ + && npm config rm https-proxy \ + && npm config set fetch-retries 5 \ + && npm config set fetch-retry-mintimeout 60000 \ + && npm config set fetch-retry-maxtimeout 120000 \ + && npm cache clean -f \ + && npm install npm@latest -g \ + && sudo setcap cap_net_raw+eip $(eval readlink -f `which node`) + +COPY docker/avahi/avahi-dbus.conf /etc/dbus-1/system.d/avahi-dbus.conf +COPY docker/bluez/bluezuser.conf /etc/dbus-1/system.d/bluezuser.conf +RUN mkdir -p /var/run/dbus/ \ + && chmod -R 777 /var/run/dbus/ \ + && mkdir -p /var/run/avahi-daemon/ \ + && chmod -R 777 /var/run/avahi-daemon/ \ + && chown -R avahi:avahi /var/run/avahi-daemon/ diff --git a/docker/Dockerfile_rel_test b/docker/Dockerfile_rel_test new file mode 100644 index 000000000..84710ff1f --- /dev/null +++ b/docker/Dockerfile_rel_test @@ -0,0 +1,25 @@ +FROM cr.signalk.io/signalk/signalk-server-base:latest_test + +RUN npm config rm proxy \ + && npm config rm https-proxy \ + && npm config set fetch-retries 5 \ + && npm config set fetch-retry-mintimeout 60000 \ + && npm config set fetch-retry-maxtimeout 120000 \ + && npm cache clean -f + +ARG TAG + +RUN npm i -g signalk-server@$TAG \ + && ln -s /usr/lib/node_modules/signalk-server /home/node/signalk + +WORKDIR /home/node/signalk +COPY docker/startup_test.sh startup.sh +RUN chmod +x startup.sh + +USER node +RUN mkdir -p /home/node/.signalk + +EXPOSE 3000 +ENV IS_IN_DOCKER true +WORKDIR /home/node/.signalk +ENTRYPOINT /home/node/signalk/startup.sh diff --git a/docker/Dockerfile_test b/docker/Dockerfile_test new file mode 100644 index 000000000..50798ba1d --- /dev/null +++ b/docker/Dockerfile_test @@ -0,0 +1,41 @@ +FROM cr.signalk.io/signalk/signalk-server-base:latest_test AS base + +USER node +RUN mkdir -p /home/node/.signalk/ \ + && mkdir -p /home/node/signalk/ + +WORKDIR /home/node/signalk + +RUN npm config rm proxy \ + && npm config rm https-proxy \ + && npm config set fetch-retries 5 \ + && npm config set fetch-retry-mintimeout 60000 \ + && npm config set fetch-retry-maxtimeout 120000 \ + && npm cache clean -f + +FROM base AS tarballs_installed +WORKDIR /home/node/signalk +COPY *.tgz . +USER root + +RUN npm i -g signalk-server-*.tgz +# move server-admin-ui that gets installed as sibling of signalk-server +RUN mv /usr/lib/node_modules/@signalk/* /usr/lib/node_modules/signalk-server/node_modules/@signalk/ + +FROM base + +USER root +# add signalk-server on path like in production build +RUN ln -s /usr/lib/node_modules/signalk-server/bin/signalk-server /usr/bin/signalk-server +# all -g installed modules +COPY --from=tarballs_installed /usr/lib/node_modules /usr/lib/node_modules + +USER node +COPY --chown=node docker/startup_test.sh startup.sh +RUN chmod +x startup.sh + +EXPOSE 3000 +ENV IS_IN_DOCKER true +ENV SKIP_ADMINUI_VERSION_CHECK true +WORKDIR /home/node/.signalk +ENTRYPOINT /home/node/signalk/startup.sh diff --git a/docker/startup_test.sh b/docker/startup_test.sh new file mode 100644 index 000000000..f3ec78d25 --- /dev/null +++ b/docker/startup_test.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh +service dbus restart +/usr/sbin/avahi-daemon -k +/usr/sbin/avahi-daemon --no-drop-root & +service bluetooth restart +node --trace-deprecation /usr/lib/node_modules/signalk-server/bin/signalk-server --securityenabled \ No newline at end of file From ba267923534bfab1fe852368e084ca95c67e6ee5 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Wed, 13 Nov 2024 11:20:09 +0200 Subject: [PATCH 3/4] fix: suffix added for test images --- .github/workflows/build-docker-test.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docker-test.yml b/.github/workflows/build-docker-test.yml index 416f46402..90288caaf 100644 --- a/.github/workflows/build-docker-test.yml +++ b/.github/workflows/build-docker-test.yml @@ -58,6 +58,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: | + signalk/signalk-server + ghcr.io/signalk/signalk-server + tags: | + type=ref,event=branch,suffix=-test + type=sha,suffix=-test - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -84,6 +94,4 @@ jobs: file: ./docker/Dockerfile_test platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true - tags: | - signalk/signalk-server:latest_test - ghcr.io/signalk/signalk-server:latest_test + tags: ${{ steps.docker_meta.outputs.tags }} From 9bc47444053febf49b3a517eb48c6831b634be28 Mon Sep 17 00:00:00 2001 From: Karl-Erik Gustafsson Date: Sun, 15 Dec 2024 17:53:58 +0200 Subject: [PATCH 4/4] fix: action name change --- .github/workflows/build-docker-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-test.yml b/.github/workflows/build-docker-test.yml index 90288caaf..bab66568c 100644 --- a/.github/workflows/build-docker-test.yml +++ b/.github/workflows/build-docker-test.yml @@ -1,4 +1,4 @@ -name: Build Docker development test container +name: Build Docker development test image on: push: