diff --git a/.dockerignore b/.dockerignore index a7239bc..3004a32 100644 --- a/.dockerignore +++ b/.dockerignore @@ -26,8 +26,7 @@ build # Local secrets and runtime/test artifacts never belong in the build context. .env .env.* -.data -.data-dev +.data* test-results playwright-report tests diff --git a/.env.example b/.env.example index cc5f742..22ee0e8 100644 --- a/.env.example +++ b/.env.example @@ -3,11 +3,6 @@ PORT=3000 # Listen on LAN interfaces as well as localhost. CONSOLE_HOST=0.0.0.0 -# Only M3ter Manager requires login. Console itself is public. -M3TER_MANAGER_USERNAME=admin -M3TER_MANAGER_PASSWORD= -# Optional global telemetry history limit; invalid values fall back to 100. -# M3TER_TELEMETRY_LIMIT=100 # Module Configuration BACKEND_MODULES="core/arweave,core/is_on,core/prover,core/streamr" @@ -22,13 +17,9 @@ CHIRPSTACK_HOST=localhost # CHEFSTACK_URL=http://localhost:8080 # CHIRPSTACK_WEB_URL remains supported; CHEFSTACK_URL takes precedence. # CHIRPSTACK_WEB_URL=http://localhost:8080 -# M3ter Manager uses the existing ChirpStack v4 REST proxy and the same API_TOKEN. -# This is the REST proxy's port, NOT the ChirpStack web UI port. -# CHIRPSTACK_REST_URL=http://localhost:8090 -# Both consumers share this optional broker URL (mqtt/mqtts/ws/wss). +# Optional broker URL (mqtt/mqtts/ws/wss). # When absent, preserve CHIRPSTACK_HOST on port 1883, default localhost. # MQTT_URL=mqtt://localhost:1883 -# M3TER_INACTIVE_SECONDS=300 # Contract & Network Configuration CONTRACT_LABEL=M3ters @@ -43,3 +34,48 @@ STREAMR_CRONSCHEDULE="0 * * * *" # Every hour # Optional: Prover Node (disabled publishing to prover if not set) # PREFERRED_PROVER_NODE="https://prover.m3ter.ing" # PROVER_CRONSCHEDULE="0 0 * * *" # Every 24 hours + +# Centralized Console feature branch — opt-in configuration contract. +# See docs/centralized/deployment.md and its test/release gates before opting in. +# Existing installations remain standalone. +# CONSOLE_ROLE=standalone +# CENTRAL_URL=wss://console.example.invalid +# AGENT_CREDENTIAL_PATH=/opt/app/.data/agent/credential +# FALLBACK_SECRET_PATH=/opt/app/.data/agent/fallback-secret +# CENTRAL_DECISION_TIMEOUT_MS=8000 +# CENTRAL_RECOVERY_HEALTHY_MS=15000 +# AGENT_QUEUE_LIMIT=10000 +# Never enable this outside isolated development fixtures. +# CENTRAL_ALLOW_INSECURE_DEVELOPMENT=false +# Only explicit reverse-proxy peer IPs; forwarded headers are otherwise ignored. +# CENTRAL_TRUSTED_PROXIES=127.0.0.1,::1 +# One-time token from central enrollment; remove it after the credential file exists. +# AGENT_ENROLLMENT_TOKEN=REPLACE_WITH_ONE_TIME_TOKEN +# Central bootstrap only; password must have at least 16 characters. +# CENTRAL_ADMIN_USERNAME=admin +# CENTRAL_ADMIN_PASSWORD=REPLACE_WITH_A_UNIQUE_LONG_PASSWORD +# Loopback authenticated fallback. Never publish this port through a proxy. +# GATEWAY_FALLBACK_PORT=3001 +# Gateway-owned tunnel policy; central cannot override these targets. +# AGENT_SSH_PORT=22 +# AGENT_BROWSER_ALLOW_LAN=false +# AGENT_BROWSER_PORTS=80,443,3000,8080,8090 +# Used only by compose.central.yaml's TLS proxy. +# CENTRAL_DOMAIN=console.example.invalid + +# Optional browser image (Chromium is absent from the default gateway image). +# BROWSER_IMAGE=ghcr.io/fluxion9/console-browser:feat-centralized-console +# BROWSER_EXECUTABLE=/usr/bin/chromium + +# Optional separate updater; disabled locally by default. Never mount Docker in agent. +# REMOTE_UPDATES_ENABLED=false +# UPDATER_IMAGE=ghcr.io/fluxion9/console-updater:feat-centralized-console +# UPDATER_IMAGE_REPOSITORY=ghcr.io/fluxion9/console +# UPDATER_SOURCE_REPOSITORY=fluxion9/Console +# UPDATER_ALLOWED_REFS=refs/heads/main +# Explicit test-only trust: refs/heads/main,refs/heads/feat/centralized-console +# COMPOSE_PROJECT_NAME=console +# UPDATER_DEPLOY_DIRECTORY=/absolute/host/path/to/Console +# UPDATER_RECONNECT_TIMEOUT_MS=180000 +# Registry/API access token for gh verification, only in the updater container. +# UPDATER_GITHUB_TOKEN=REPLACE_WITH_READ_ONLY_VERIFICATION_TOKEN diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7b9a37..6540f4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,8 @@ jobs: strategy: fail-fast: false matrix: + platform: [linux/amd64, linux/arm64] + variant: [console, browser, updater] include: - platform: linux/amd64 runner: ubuntu-latest @@ -61,7 +63,9 @@ jobs: - name: Normalize image names run: | - echo "CONSOLE_IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV" + suffix="" + if [[ "${{ matrix.variant }}" != console ]]; then suffix="-${{ matrix.variant }}"; fi + echo "CONSOLE_IMAGE_NAME=${GITHUB_REPOSITORY,,}$suffix" >> "$GITHUB_ENV" - name: Free disk space uses: jlumbroso/free-disk-space@main @@ -93,38 +97,56 @@ jobs: with: context: . platforms: ${{ matrix.platform }} + target: ${{ matrix.variant }} push: ${{ github.event_name != 'pull_request' }} outputs: type=image,name=${{ env.REGISTRY }}/${{ env.CONSOLE_IMAGE_NAME }},push-by-digest=true cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.CONSOLE_IMAGE_NAME }}:buildcache-${{ matrix.arch }} cache-to: ${{ github.event_name != 'pull_request' && format('type=registry,ref={0}/{1}:buildcache-{2},mode=max', env.REGISTRY, env.CONSOLE_IMAGE_NAME, matrix.arch) || '' }} + - name: Attest published platform image + if: github.event_name != 'pull_request' + uses: actions/attest@v4 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.CONSOLE_IMAGE_NAME }} + subject-digest: ${{ steps.build-console.outputs.digest }} + push-to-registry: true + create-storage-record: false + - name: Save digests to files if: github.event_name != 'pull_request' run: | - echo ${{ steps.build-console.outputs.digest }} > digests-${{ matrix.arch }}-console-digest.txt + echo ${{ steps.build-console.outputs.digest }} > digests-${{ matrix.arch }}-${{ matrix.variant }}-digest.txt - name: Upload digests artifact if: github.event_name != 'pull_request' uses: actions/upload-artifact@v6 with: - name: digests-${{ matrix.arch }} + name: digests-${{ matrix.arch }}-${{ matrix.variant }} path: | - digests-${{ matrix.arch }}-console-digest.txt + digests-${{ matrix.arch }}-${{ matrix.variant }}-digest.txt create-manifests: + strategy: + matrix: + variant: [console, browser, updater] needs: build-platform if: github.event_name != 'pull_request' runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v5 + - name: Normalize image names run: | - echo "CONSOLE_IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV" + suffix="" + if [[ "${{ matrix.variant }}" != console ]]; then suffix="-${{ matrix.variant }}"; fi + echo "CONSOLE_IMAGE_NAME=${GITHUB_REPOSITORY,,}$suffix" >> "$GITHUB_ENV" - name: Download all digests uses: actions/download-artifact@v7 with: - pattern: digests-* + pattern: digests-*-${{ matrix.variant }} merge-multiple: true - name: Log in to GitHub Container Registry @@ -144,11 +166,12 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.CONSOLE_IMAGE_NAME }} - name: Create multi-arch manifest for Console + id: manifest env: IMAGE_TAGS: ${{ steps.meta-console.outputs.tags }} run: | - AMD64_DIGEST=$(cat digests-amd64-console-digest.txt) - ARM64_DIGEST=$(cat digests-arm64-console-digest.txt) + AMD64_DIGEST=$(cat digests-amd64-${{ matrix.variant }}-digest.txt) + ARM64_DIGEST=$(cat digests-arm64-${{ matrix.variant }}-digest.txt) echo "AMD64_DIGEST=$AMD64_DIGEST" echo "ARM64_DIGEST=$ARM64_DIGEST" TAG_ARGS=() @@ -157,6 +180,18 @@ jobs: TAG_ARGS+=(--tag "$tag") fi done <<< "$IMAGE_TAGS" - docker buildx imagetools create "${TAG_ARGS[@]}" \ + docker buildx imagetools create --metadata-file manifest.json "${TAG_ARGS[@]}" \ "$REGISTRY/$CONSOLE_IMAGE_NAME@$AMD64_DIGEST" \ "$REGISTRY/$CONSOLE_IMAGE_NAME@$ARM64_DIGEST" + + DIGEST=$(jq -r '."containerimage.descriptor".digest' manifest.json) + [[ "$DIGEST" =~ ^sha256:[a-f0-9]{64}$ ]] + echo "digest=$DIGEST" >> "$GITHUB_OUTPUT" + + - name: Attest published multi-architecture manifest + uses: actions/attest@v4 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.CONSOLE_IMAGE_NAME }} + subject-digest: ${{ steps.manifest.outputs.digest }} + push-to-registry: true + create-storage-record: false diff --git a/.gitignore b/.gitignore index 1d72804..7e2c1a6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ script.*.js # Database files *.db +*.db-wal +*.db-shm +.data*/ src/db # data files @@ -93,6 +96,8 @@ web_modules/ .env.test.local .env.production.local .env.local +.env.* +!.env.example # parcel-bundler cache (https://parceljs.org/) .cache diff --git a/Dockerfile b/Dockerfile index 631fc18..7417608 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine +FROM node:20-alpine AS runtime # Use Node.js headers bundled with the base image ENV npm_config_nodedir=/usr/local @@ -32,3 +32,23 @@ ENTRYPOINT ["/entrypoint.sh"] # Start app CMD [ "npm", "start" ] + +# Optional browser image. Default builds below never install Chromium. +FROM runtime AS browser +RUN apk add --no-cache chromium openssl \ + && mkdir -p /opt/app/.data /opt/app/src/extensions /opt/app/dist/extensions \ + && chown -R node:node /opt/app/.data /opt/app/src/extensions /opt/app/dist/extensions +ENV BROWSER_EXECUTABLE=/usr/bin/chromium +USER node +# Build-only smoke check has no target service/network. Runtime requires sandbox. +RUN timeout 30 chromium --headless --no-sandbox --disable-gpu --disable-dev-shm-usage --no-first-run --disable-background-networking --proxy-server=http://127.0.0.1:9 --dump-dom about:blank > /tmp/browser-smoke.html \ + && grep -q '