Files
low-code-react-app-b/DOCKER_BUILD_FIX.md
johndoe6345789 0277dad468 Generated by Spark: Run docker/build-push-action@v5
GitHub Actions runtime token ACs
Docker info
  /usr/bin/docker version
  Client: Docker Engine - Community
   Version:           28.0.4
   API version:       1.48
   Go version:        go1.23.7
   Git commit:        b8034c0
   Built:             Tue Mar 25 15:07:16 2025
   OS/Arch:           linux/amd64
   Context:           default
  Server: Docker Engine - Community
   Engine:
    Version:          28.0.4
    API version:      1.48 (minimum version 1.24)
    Go version:       go1.23.7
    Git commit:       6430e49
    Built:            Tue Mar 25 15:07:16 2025
    OS/Arch:          linux/amd64
    Experimental:     false
   containerd:
    Version:          v2.2.1
    GitCommit:        dea7da592f5d1d2b7755e3a161be07f43fad8f75
   runc:
    Version:          1.3.4
    GitCommit:        v1.3.4-0-gd6d73eb8
   docker-init:
    Version:          0.19.0
    GitCommit:        de40ad0
  /usr/bin/docker info
  Client: Docker Engine - Community
   Version:    28.0.4
   Context:    default
   Debug Mode: false
   Plugins:
    buildx: Docker Buildx (Docker Inc.)
      Version:  v0.30.1
      Path:     /usr/libexec/docker/cli-plugins/docker-buildx
    compose: Docker Compose (Docker Inc.)
      Version:  v2.38.2
      Path:     /usr/libexec/docker/cli-plugins/docker-compose
  Server:
   Containers: 1
    Running: 1
    Paused: 0
    Stopped: 0
   Images: 2
   Server Version: 28.0.4
   Storage Driver: overlay2
    Backing Filesystem: extfs
    Supports d_type: true
    Using metacopy: false
    Native Overlay Diff: false
    userxattr: false
   Logging Driver: json-file
   Cgroup Driver: systemd
   Cgroup Version: 2
   Plugins:
    Volume: local
    Network: bridge host ipvlan macvlan null overlay
    Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
   Swarm: inactive
   Runtimes: io.containerd.runc.v2 runc
   Default Runtime: runc
   Init Binary: docker-init
   containerd version: dea7da592f5d1d2b7755e3a161be07f43fad8f75
   runc version: v1.3.4-0-gd6d73eb8
   init version: de40ad0
   Security Options:
    apparmor
    seccomp
     Profile: builtin
    cgroupns
   Kernel Version: 6.11.0-1018-azure
   Operating System: Ubuntu 24.04.3 LTS
   OSType: linux
   Architecture: x86_64
   CPUs: 4
   Total Memory: 15.62GiB
   Name: runnervmmtnos
   ID: 5a446069-012f-4a61-9e1e-c3a17d5c9c05
   Docker Root Dir: /var/lib/docker
   Debug Mode: false
   Username: githubactions
   Experimental: false
   Insecure Registries:
    ::1/128
    127.0.0.0/8
   Live Restore Enabled: false
Proxy configuration
Buildx version
Builder info
  {
    "nodes": [
      {
        "name": "builder-c2405014-ff21-4a4f-b302-39a9ae5c71c80",
        "endpoint": "unix:///var/run/docker.sock",
        "status": "running",
        "buildkitd-flags": "--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host",
        "buildkit": "v0.26.3",
        "platforms": "linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/386",
        "features": {
          "Automatically load images to the Docker Engine image store": true,
          "Cache export": true,
          "Direct push": true,
          "Docker exporter": true,
          "Multi-platform build": true,
          "OCI exporter": true
        },
        "labels": {
          "org.mobyproject.buildkit.worker.executor": "oci",
          "org.mobyproject.buildkit.worker.hostname": "40a4db72e58c",
          "org.mobyproject.buildkit.worker.network": "host",
          "org.mobyproject.buildkit.worker.oci.process-mode": "sandbox",
          "org.mobyproject.buildkit.worker.selinux.enabled": "false",
          "org.mobyproject.buildkit.worker.snapshotter": "overlayfs"
        },
        "gcPolicy": [
          {
            "all": false,
            "filter": [
              "type==source.local",
              "type==exec.cachemount",
              "type==source.git.checkout"
            ],
            "keepDuration": "48h0m0s"
          },
          {
            "all": false,
            "keepDuration": "1440h0m0s"
          },
          {
            "all": false
          },
          {
            "all": true
          }
        ]
      }
    ],
    "name": "builder-c2405014-ff21-4a4f-b302-39a9ae5c71c8",
    "driver": "docker-container",
    "lastActivity": "2026-01-17T13:24:40.000Z"
  }

/usr/bin/docker buildx build --cache-from type=gha --cache-to type=gha,mode=max --iidfile /home/runner/work/_temp/docker-actions-toolkit-El61kn/build-iidfile-2d9f27503a.txt --label org.opencontainers.image.created=2026-01-17T13:24:46.055Z --label org.opencontainers.image.description= --label org.opencontainers.image.licenses=MIT --label org.opencontainers.image.revision=e1e2ffef1939450402f35d11b026c324cee03329 --label org.opencontainers.image.source=https://github.com/johndoe6345789/low-code-react-app-b --label org.opencontainers.image.title=low-code-react-app-b --label org.opencontainers.image.url=https://github.com/johndoe6345789/low-code-react-app-b --label org.opencontainers.image.version=main --attest type=provenance,mode=max,builder-id=https://github.com/johndoe6345789/low-code-react-app-b/actions/runs/21094949820 --tag ghcr.io/johndoe6345789/low-code-react-app-b:main --tag ghcr.io/johndoe6345789/low-code-react-app-b:main-e1e2ffe --metadata-file /home/runner/work/_temp/docker-actions-toolkit-El
#0 building with "builder-c2405014-ff21-4a4f-b302-39a9ae5c71c8" instance using docker-container driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 825B done
#1 DONE 0.0s
#2 [internal] load metadata for docker.io/library/node:20-alpine
#2 ...
#3 [auth] library/nginx:pull token for registry-1.docker.io
#3 DONE 0.0s
#4 [auth] library/node:pull token for registry-1.docker.io
#4 DONE 0.0s
#5 [internal] load metadata for docker.io/library/nginx:alpine
#5 DONE 1.0s
#2 [internal] load metadata for docker.io/library/node:20-alpine
#2 DONE 1.0s
#6 [internal] load .dockerignore
#6 transferring context: 246B done
#6 DONE 0.0s
#7 [internal] load build context
#7 DONE 0.0s
#8 [builder 1/8] FROM docker.io/library/node:20-alpine@sha256:3960ed74dfe320a67bf8da9555b6bade25ebda2b22b6081d2f60fd7d5d430e9c
#8 resolve docker.io/library/node:20-alpine@sha256:3960ed74dfe320a67bf8da9555b6bade25ebda2b22b6081d2f60fd7d5d430e9c done
#8 DONE 0.0s
#9 [runtime 1/3] FROM docker.io/library/nginx:alpine@sha256:b0f7830b6bfaa1258f45d94c240ab668ced1b3651c8a222aefe6683447c7bf55
#9 resolve docker.io/library/nginx:alpine@sha256:b0f7830b6bfaa1258f45d94c240ab668ced1b3651c8a222aefe6683447c7bf55 done
#9 DONE 0.0s
#10 importing cache manifest from gha:10659997648410108985
#10 DONE 0.2s
#7 [internal] load build context
#7 transferring context: 10.14MB 0.2s done
#7 DONE 0.2s
#8 [builder 1/8] FROM docker.io/library/node:20-alpine@sha256:3960ed74dfe320a67bf8da9555b6bade25ebda2b22b6081d2f60fd7d5d430e9c
#8 sha256:41b3afaea3b1b1ab04a268431e10dcace7883019a5da7d326aa35dc9713fcbb5 445B / 445B 0.1s done
#8 sha256:3dcec91425079e7b455efc5f2a18d026450c47c9382c41897620afc6b1424e44 1.26MB / 1.26MB 0.1s done
#8 sha256:c2b4197efb6ccd7f8b482ae7800f1c9c78c044ea192587887300080bcff6b2c9 0B / 42.78MB 0.2s
#8 sha256:1074353eec0db2c1d81d5af2671e56e00cf5738486f5762609ea33d606f88612 3.86MB / 3.86MB 0.2s done
#8 extracting sha256:1074353eec0db2c1d81d5af2671e56e00cf5738486f5762609ea33d606f88612 0.1s done
#8 sha256:c2b4197efb6ccd7f8b482ae7800f1c9c78c044ea192587887300080bcff6b2c9 42.78MB / 42.78MB 0.4s done
#8 extracting sha256:c2b4197efb6ccd7f8b482ae7800f1c9c78c044ea192587887300080bcff6b2c9
#8 ...
#9 [runtime 1/3] FROM docker.io/library/nginx:alpine@sha256:b0f7830b6bfaa1258f45d94c240ab668ced1b3651c8a222aefe6683447c7bf55
#9 sha256:0abf9e5672665202e79f26f23ef5dbd12558e2ea51ac32807922ab76fdb24ab0 1.40kB / 1.40kB 0.1s done
#9 sha256:e096540205d5d1ab2c2647d716491020d81e3f167a33606665b193d75540857f 20.18MB / 20.18MB 0.3s done
#9 sha256:085c5e5aaa8eb4b957ecf253c74f16a6a5551231de3fb7c3ac74814a6bf17e06 1.21kB / 1.21kB 0.1s done
#9 sha256:33f95a0f3229b49e777082e801b882b13fcc5b4e389410ce8eb066f4d58c71b9 403B / 403B 0.1s done
#9 sha256:da7c973d8b92a1555060972c8849a332c93bfe2608c11faeee2098c4cfbe8c3d 953B / 953B 0.1s done
#9 sha256:25f453064fd3e8a9754b6e51b86c637e13203cbfc748fcf73f3c8b2d10816ae3 1.86MB / 1.86MB 0.1s done
#9 extracting sha256:25f453064fd3e8a9754b6e51b86c637e13203cbfc748fcf73f3c8b2d10816ae3 0.1s done
#9 sha256:567f84da6fbd4287d40a5837485469435c40a81f9a94e98395b6385d3600643a 626B / 626B 0.1s done
#9 DONE 0.6s
#9 [runtime 1/3] FROM docker.io/library/nginx:alpine@sha256:b0f7830b6bfaa1258f45d94c240ab668ced1b3651c8a222aefe6683447c7bf55
#9 extracting sha256:567f84da6fbd4287d40a5837485469435c40a81f9a94e98395b6385d3600643a done
#9 extracting sha256:da7c973d8b92a1555060972c8849a332c93bfe2608c11faeee2098c4cfbe8c3d done
#9 extracting sha256:33f95a0f3229b49e777082e801b882b13fcc5b4e389410ce8eb066f4d58c71b9 done
#9 extracting sha256:085c5e5aaa8eb4b957ecf253c74f16a6a5551231de3fb7c3ac74814a6bf17e06 done
#9 extracting sha256:0abf9e5672665202e79f26f23ef5dbd12558e2ea51ac32807922ab76fdb24ab0 done
#9 extracting sha256:e096540205d5d1ab2c2647d716491020d81e3f167a33606665b193d75540857f
#9 extracting sha256:e096540205d5d1ab2c2647d716491020d81e3f167a33606665b193d75540857f 0.4s done
#9 DONE 1.0s
#8 [builder 1/8] FROM docker.io/library/node:20-alpine@sha256:3960ed74dfe320a67bf8da9555b6bade25ebda2b22b6081d2f60fd7d5d430e9c
#8 extracting sha256:c2b4197efb6ccd7f8b482ae7800f1c9c78c044ea192587887300080bcff6b2c9 1.1s done
#8 DONE 1.5s
#8 [builder 1/8] FROM docker.io/library/node:20-alpine@sha256:3960ed74dfe320a67bf8da9555b6bade25ebda2b22b6081d2f60fd7d5d430e9c
#8 extracting sha256:3dcec91425079e7b455efc5f2a18d026450c47c9382c41897620afc6b1424e44 0.0s done
#8 extracting sha256:41b3afaea3b1b1ab04a268431e10dcace7883019a5da7d326aa35dc9713fcbb5 done
#8 DONE 1.5s
#11 [builder 2/8] WORKDIR /app
#11 DONE 0.3s
#12 [builder 3/8] COPY package*.json ./
#12 DONE 0.0s
#13 [builder 4/8] COPY packages/spark/package.json ./packages/spark/package.json
#13 DONE 0.0s
#14 [builder 5/8] COPY packages/spark/src ./packages/spark/src
#14 DONE 0.0s
#15 [builder 6/8] RUN npm install
#15 0.858 npm error code EUNSUPPORTEDPROTOCOL
#15 0.859 npm error Unsupported URL Type "workspace:": workspace:*
#15 0.861 npm notice
#15 0.861 npm notice New major version of npm available! 10.8.2 -> 11.7.0
#15 0.861 npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.7.0
#15 0.861 npm notice To update run: npm install -g npm@11.7.0
#15 0.861 npm notice
#15 0.862 npm error A complete log of this run can be found in: /root/.npm/_logs/2026-01-17T13_24_50_210Z-debug-0.log
#15 ERROR: process "/bin/sh -c npm install" did not complete successfully: exit code: 1
------
 > [builder 6/8] RUN npm install:
0.858 npm error code EUNSUPPORTEDPROTOCOL
0.859 npm error Unsupported URL Type "workspace:": workspace:*
0.861 npm notice
0.861 npm notice New major version of npm available! 10.8.2 -> 11.7.0
0.861 npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.7.0
0.861 npm notice To update run: npm install -g npm@11.7.0
0.861 npm notice
0.862 npm error A complete log of this run can be found in: /root/.npm/_logs/2026-01-17T13_24_50_210Z-debug-0.log
------
Dockerfile:12
--------------------
  10 |     # Install dependencies
  11 |     # Note: npm ci doesn't work reliably with workspace: protocol, so we use npm install
  12 | >>> RUN npm install
  13 |
  14 |     # Copy remaining application files
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1
Error: buildx failed with: ERROR: failed to build: failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1
2026-01-17 13:28:58 +00:00

3.5 KiB

Docker Build Fix - Workspace Protocol Resolution

Problem Summary

The Docker build was failing with the error:

npm error code EUNSUPPORTEDPROTOCOL
npm error Unsupported URL Type "workspace:": workspace:*

This occurred because:

  1. The package.json uses "@github/spark": "workspace:*" to reference the local workspace package
  2. npm's standard install doesn't properly resolve workspace protocols without the full workspace structure
  3. The Dockerfile wasn't copying the complete workspace setup needed for proper dependency resolution

Solution Implemented

1. Updated Dockerfile

The Dockerfile now properly handles npm workspaces:

FROM node:20-alpine AS builder

WORKDIR /app

# Copy workspace configuration and all package files
COPY package*.json ./

# Copy spark-tools package (the actual @github/spark implementation)
COPY packages/spark-tools/package.json ./packages/spark-tools/package.json
COPY packages/spark-tools/dist ./packages/spark-tools/dist

# Copy spark wrapper package
COPY packages/spark/package.json ./packages/spark/package.json
COPY packages/spark/src ./packages/spark/src
COPY packages/spark/tsconfig.json ./packages/spark/tsconfig.json

# Install dependencies using npm workspaces
RUN npm install --workspaces --include-workspace-root

# Copy remaining application files
COPY . .

# Build the application
RUN npm run build

Key changes:

  • Copies the complete workspace structure (both packages/spark and packages/spark-tools)
  • Uses npm install --workspaces --include-workspace-root to properly resolve workspace dependencies
  • Includes the pre-built dist folder from spark-tools (required for the build)

2. Updated .dockerignore

Modified to exclude build artifacts but preserve the essential spark-tools/dist:

node_modules
npm-debug.log
.git
.github
*.md
!README.md

# Keep the dist folder in packages/spark-tools (needed for build)
!packages/spark-tools/dist

3. Updated GitHub Actions Workflows

All npm install commands in .github/workflows/ci.yml now use:

npm install --workspaces --legacy-peer-deps

This ensures:

  • Proper workspace resolution in CI
  • Consistent behavior between local development and CI
  • Avoids peer dependency conflicts

Why This Works

  1. Workspace Protocol: npm workspaces require the full workspace structure to resolve workspace:* dependencies
  2. Pre-built Assets: The spark-tools/dist folder contains the compiled @github/spark package that the main app depends on
  3. Consistent Commands: Using --workspaces flag ensures npm properly links local packages

Testing the Fix

Local Docker Build

docker build -t codeforge:test .

GitHub Actions

The fix will automatically apply when you push to main or develop branches. The workflow will:

  1. Install dependencies with workspace support
  2. Build the Docker image using the updated Dockerfile
  3. Push to GitHub Container Registry

Alternative Solutions Considered

  1. Remove workspace protocol: Replace workspace:* with file paths - rejected because it breaks the monorepo structure
  2. Use pnpm: Better workspace support - rejected because it requires changing the entire toolchain
  3. Flatten dependencies: Copy spark into node_modules - rejected because it's a workaround, not a fix

Maintenance Notes

  • Always ensure packages/spark-tools/dist is built before creating Docker images
  • If you modify workspace structure, update the Dockerfile COPY commands accordingly
  • The --legacy-peer-deps flag may be removed once all peer dependencies are resolved