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

feature: ubuntu 24.04 and node22 for docker image #1826

Closed
Closed
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
66 changes: 66 additions & 0 deletions .github/workflows/build-base-image-test.yml
Original file line number Diff line number Diff line change
@@ -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
97 changes: 97 additions & 0 deletions .github/workflows/build-docker-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Build Docker development test image

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: 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
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: ${{ steps.docker_meta.outputs.tags }}
2 changes: 1 addition & 1 deletion docker/Dockerfile_base
Original file line number Diff line number Diff line change
Expand Up @@ -23,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/
27 changes: 27 additions & 0 deletions docker/Dockerfile_base_test
Original file line number Diff line number Diff line change
@@ -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/
25 changes: 25 additions & 0 deletions docker/Dockerfile_rel_test
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions docker/Dockerfile_test
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions docker/startup_test.sh
Original file line number Diff line number Diff line change
@@ -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
Loading