From 95cc5bf5dbc322ea124b0dad9644cb4600b432df Mon Sep 17 00:00:00 2001 From: Calvin T Park <198585361+CalvinTPark@users.noreply.github.com> Date: Sat, 10 Jan 2026 16:37:02 +0000 Subject: [PATCH 1/3] ci: test docker build images --- .dockerignore | 5 ++++ .gitattributes | 1 + .github/workflows/build-and-push.yaml | 1 + .github/workflows/ci.yml | 43 +++++++++++++++++++++++++++ Dockerfile | 41 +++++++++++++++++++++++-- docker-bake.hcl | 23 ++++++++++++++ 6 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 .gitattributes create mode 100644 .github/workflows/ci.yml create mode 100644 docker-bake.hcl diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5ea9a79 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +**/.DS_Store +**/Thumbs.db + +.github +assets diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index 79f3df3..4e8a0f1 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -52,3 +52,4 @@ jobs: ${{ vars.DOCKER_ORG }}/spfx:${{ env.docker_image_tag_name }} ${{ vars.DOCKER_ORG }}/spfx:latest ${{ vars.DOCKER_ORG }}/spfx:online + target: default diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9848d58 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: ci + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: docker/setup-buildx-action@v3 + with: + cleanup: false + - uses: docker/bake-action@v6.10.0 + with: + source: . + targets: default + push: false + set: | + *.cache-from=type=gha,scope=dockerspfx + *.cache-to=type=gha,scope=dockerspfx,mode=max + + test: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v6 + - uses: docker/setup-buildx-action@v3 + with: + cleanup: false + - uses: docker/bake-action@v6.10.0 + with: + source: . + targets: test + push: false + set: | + *.cache-from=type=gha,scope=dockerspfx + *.cache-to=type=gha,scope=dockerspfx,mode=max diff --git a/Dockerfile b/Dockerfile index 9dc2eaa..9a608e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM node:22.16.0 +# ----------------- default (start) ----------------------- + +FROM node:22.16.0 AS default EXPOSE 4321 35729 @@ -16,4 +18,39 @@ USER spfx RUN npm i --location=global gulp-cli@3 yo pnpm RUN npm i --location=global @microsoft/generator-sharepoint@1.21.1 -CMD /bin/bash \ No newline at end of file +CMD /bin/bash + +# ----------------- default (end) --------------------------- + + +# ----------------- test-base (start) ----------------------- + +FROM default AS test-base + +RUN mkdir -p test/.pnpm-store +WORKDIR test + +# ----------------- test-base (end) ----------------------- + + +# ----------------- test-webpart (start) ------------------ + +FROM test-base AS test-webpart + +RUN yo @microsoft/sharepoint --component-type webpart \ + --solution-name spfx-webpart \ + --component-name HelloWorld \ + --framework react \ + --package-manager pnpm \ + --skip-install + +WORKDIR spfx-webpart + +RUN --mount=type=cache,target=/usr/app/spfx/test/.pnpm-store,sharing=locked \ + pnpm install + +RUN pnpm build + +WORKDIR .. + +# ----------------- test-webpart (end) ------------------ diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 0000000..4867bc2 --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,23 @@ +target "default" { + target = "default" + tags = [ + "docker.io/m365pnp/spfx:latest", + "docker.io/m365pnp/spfx:online" + ] + platforms = [ + "linux/amd64", + "linux/arm64/v8" + ] +} + + +target "test" { + targets = [ + "test-webpart" + ] + output = ["type=cacheonly"] + platforms = [ + "linux/amd64", + "linux/arm64/v8" + ] +} From 5926e04f128a31c982edec661a8b5fd90ad2b924 Mon Sep 17 00:00:00 2001 From: Calvin T Park <198585361+CalvinTPark@users.noreply.github.com> Date: Sat, 10 Jan 2026 16:48:26 +0000 Subject: [PATCH 2/3] docs: build container instructions --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 172a1fd..9840edf 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,17 @@ You can also use this image for [Visual Studio development containers](./Develop - **drop-5**: contains the SharePoint Framework Yeoman generator from the [developer preview drop 5](https://github.com/SharePoint/sp-dev-docs/wiki/Release-Notes-Drop-5) - **drop-4**: contains the SharePoint Framework Yeoman generator from the [developer preview drop 4](https://github.com/SharePoint/sp-dev-docs/wiki/Release-Notes-Drop-4-and-MDL2) +### Build + +```sh +docker buildx build . --target default --tag my-spfx +``` + +```sh +cd [your project] +docker run -it --rm --name ${PWD##*/} -v $PWD:/usr/app/spfx -p 4321:4321 -p 35729:35729 my-spfx +``` + ## Known issues ### Unable to write files to disk From 5422d61cab6061b027b8874f5a0b5a23b1f106f2 Mon Sep 17 00:00:00 2001 From: Calvin T Park <198585361+CalvinTPark@users.noreply.github.com> Date: Sat, 10 Jan 2026 17:36:27 +0000 Subject: [PATCH 3/3] fix: root branch is `master` not `main` --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9848d58..8df1643 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,10 +3,10 @@ name: ci on: push: branches: - - main + - master pull_request: branches: - - main + - master jobs: build: