From 64cbf95be7f0e7f01452ff64a6b9332e1fb3dd83 Mon Sep 17 00:00:00 2001 From: Natalie Arellano Date: Fri, 8 Sep 2023 10:20:13 -0400 Subject: [PATCH 1/3] Remove Remove dotnet-framework-1809 and upgrade nanoserver To reduce the number of Windows samples and use later versions of things Signed-off-by: Natalie Arellano --- .github/workflows/build-and-deploy.yml | 2 - Makefile | 101 ++++++------------ apps/batch-script/README.md | 2 +- .../batch-script-buildpack/buildpack.toml | 2 +- builders/dotnet-framework-1809/README.md | 23 ---- builders/dotnet-framework-1809/builder.toml | 17 --- builders/nanoserver-1809/README.md | 21 ---- builders/nanoserver-2022/README.md | 21 ++++ .../builder.toml | 6 +- buildpacks/dotnet-framework/buildpack.toml | 2 +- buildpacks/hello-moon-windows/buildpack.toml | 5 +- buildpacks/hello-universe-windows/README.md | 2 +- buildpacks/hello-world-windows/README.md | 4 +- buildpacks/hello-world-windows/buildpack.toml | 2 +- stacks/dotnet-framework-1809/build/Dockerfile | 15 --- stacks/dotnet-framework-1809/run/Dockerfile | 13 --- .../base/Dockerfile | 2 +- .../build/Dockerfile | 0 .../run/Dockerfile | 0 19 files changed, 64 insertions(+), 176 deletions(-) delete mode 100644 builders/dotnet-framework-1809/README.md delete mode 100644 builders/dotnet-framework-1809/builder.toml delete mode 100644 builders/nanoserver-1809/README.md create mode 100644 builders/nanoserver-2022/README.md rename builders/{nanoserver-1809 => nanoserver-2022}/builder.toml (62%) delete mode 100644 stacks/dotnet-framework-1809/build/Dockerfile delete mode 100644 stacks/dotnet-framework-1809/run/Dockerfile rename stacks/{nanoserver-1809 => nanoserver-2022}/base/Dockerfile (85%) rename stacks/{nanoserver-1809 => nanoserver-2022}/build/Dockerfile (100%) rename stacks/{nanoserver-1809 => nanoserver-2022}/run/Dockerfile (100%) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 98b0e20b..3710cfe7 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -57,8 +57,6 @@ jobs: strategy: matrix: include: - - os: windows-2019 - version: 1809 - os: windows-2022 version: 2022 runs-on: ${{ matrix.os }} diff --git a/Makefile b/Makefile index 62a8a0be..fdbd4f56 100644 --- a/Makefile +++ b/Makefile @@ -155,50 +155,34 @@ set-experimental: ## Windows #################### -build-windows-1809: build-windows-packages build-nanoserver-1809 build-dotnet-framework-1809 - build-windows-2022: build-windows-packages build-dotnet-framework-2022 -build-nanoserver-1809: build-stack-nanoserver-1809 build-builder-nanoserver-1809 build-buildpacks-nanoserver-1809 - -build-dotnet-framework-1809: build-stack-dotnet-framework-1809 build-builder-dotnet-framework-1809 build-buildpacks-dotnet-framework-1809 +build-nanoserver-2022: build-stack-nanoserver-2022 build-builder-nanoserver-2022 build-buildpacks-nanoserver-2022 build-dotnet-framework-2022: build-stack-dotnet-framework-2022 build-builder-dotnet-framework-2022 build-buildpacks-dotnet-framework-2022 -build-stack-nanoserver-1809: - @echo "> Building 'nanoserver-1809' stack..." - bash stacks/build-stack.sh stacks/nanoserver-1809 - -build-stack-dotnet-framework-1809: - @echo "> Building 'dotnet-framework-1809' stack..." - bash stacks/build-stack.sh stacks/dotnet-framework-1809 +build-stack-nanoserver-2022: + @echo "> Building 'nanoserver-2022' stack..." + bash stacks/build-stack.sh stacks/nanoserver-2022 build-stack-dotnet-framework-2022: @echo "> Building 'dotnet-framework-2022' stack..." bash stacks/build-stack.sh stacks/dotnet-framework-2022 -build-builder-nanoserver-1809: build-windows-packages - @echo "> Building 'nanoserver-1809' builder..." - $(PACK_CMD) builder create cnbs/sample-builder:nanoserver-1809 --config $(SAMPLES_ROOT)/builders/nanoserver-1809/builder.toml $(PULL_POLICY_NEVER) - -build-builder-dotnet-framework-1809: build-windows-packages - @echo "> Building 'dotnet-framework-1809' builder..." - $(PACK_CMD) builder create cnbs/sample-builder:dotnet-framework-1809 --config $(SAMPLES_ROOT)/builders/dotnet-framework-1809/builder.toml $(PULL_POLICY_NEVER) +build-builder-nanoserver-2022: build-windows-packages + @echo "> Building 'nanoserver-2022' builder..." + $(PACK_CMD) builder create cnbs/sample-builder:nanoserver-2022 --config $(SAMPLES_ROOT)/builders/nanoserver-2022/builder.toml $(PULL_POLICY_NEVER) build-builder-dotnet-framework-2022: build-windows-packages @echo "> Building 'dotnet-framework-2022' builder..." $(PACK_CMD) builder create cnbs/sample-builder:dotnet-framework-2022 --config $(SAMPLES_ROOT)/builders/dotnet-framework-2022/builder.toml $(PULL_POLICY_NEVER) -build-buildpacks-nanoserver-1809: build-sample-root - @echo "> Creating 'hello-moon-windows' app using 'nanoserver-1809' builder..." - $(PACK_CMD) build sample-hello-moon-windows-app:nanoserver-1809 -v --builder cnbs/sample-builder:nanoserver-1809 --buildpack $(SAMPLES_ROOT)/buildpacks/hello-world-windows --buildpack $(SAMPLES_ROOT)/buildpacks/hello-moon-windows $(PULL_POLICY_NEVER) $(PACK_BUILD_FLAGS) - - @echo "> Creating 'hello-world-windows' app using 'nanoserver-1809' builder..." - $(PACK_CMD) build sample-hello-world-windows-app:nanoserver-1809 -v --builder cnbs/sample-builder:nanoserver-1809 --buildpack $(SAMPLES_ROOT)/buildpacks/hello-world-windows $(PULL_POLICY_NEVER) $(PACK_BUILD_FLAGS) +build-buildpacks-nanoserver-2022: build-sample-root + @echo "> Creating 'hello-moon-windows' app using 'nanoserver-2022' builder..." + $(PACK_CMD) build sample-hello-moon-windows-app:nanoserver-2022 -v --builder cnbs/sample-builder:nanoserver-2022 --buildpack $(SAMPLES_ROOT)/buildpacks/hello-world-windows --buildpack $(SAMPLES_ROOT)/buildpacks/hello-moon-windows $(PULL_POLICY_NEVER) $(PACK_BUILD_FLAGS) -build-buildpacks-dotnet-framework-1809: build-sample-root - @echo "> Creating 'dotnet-framework' app using 'dotnet-framework-1809' builder..." - $(PACK_CMD) build sample-dotnet-framework-app:dotnet-framework-1809 -v --builder cnbs/sample-builder:dotnet-framework-1809 --buildpack $(SAMPLES_ROOT)/buildpacks/dotnet-framework --path apps/aspnet $(PULL_POLICY_NEVER) $(PACK_BUILD_FLAGS) + @echo "> Creating 'hello-world-windows' app using 'nanoserver-2022' builder..." + $(PACK_CMD) build sample-hello-world-windows-app:nanoserver-2022 -v --builder cnbs/sample-builder:nanoserver-2022 --buildpack $(SAMPLES_ROOT)/buildpacks/hello-world-windows $(PULL_POLICY_NEVER) $(PACK_BUILD_FLAGS) build-buildpacks-dotnet-framework-2022: build-sample-root @echo "> Creating 'dotnet-framework' app using 'dotnet-framework-2022' builder..." @@ -216,72 +200,49 @@ deploy-windows-packages: docker push cnbs/sample-package:hello-world-windows docker push cnbs/sample-package:hello-universe-windows -deploy-windows-1809: deploy-windows-stacks-1809 deploy-windows-builders-1809 - deploy-windows-2022: deploy-windows-stacks-2022 deploy-windows-builders-2022 -deploy-windows-stacks-1809: deploy-windows-stacks-nanoserver-1809 deploy-windows-stacks-dotnet-framework-1809 +deploy-windows-stacks-2022: deploy-windows-stacks-dotnet-framework-2022 deploy-windows-stacks-nanoserver-2022 -deploy-windows-stacks-2022: deploy-windows-stacks-dotnet-framework-2022 - -deploy-windows-stacks-nanoserver-1809: - @echo "> Deploying 'nanoserver-1809' stack..." - docker push cnbs/sample-stack-base:nanoserver-1809 - docker push cnbs/sample-stack-run:nanoserver-1809 - docker push cnbs/sample-stack-build:nanoserver-1809 - -deploy-windows-stacks-dotnet-framework-1809: - @echo "> Deploying 'dotnet-framework-1809' stack..." - docker push cnbs/sample-stack-run:dotnet-framework-1809 - docker push cnbs/sample-stack-build:dotnet-framework-1809 +deploy-windows-stacks-nanoserver-2022: + @echo "> Deploying 'nanoserver-2022' stack..." + docker push cnbs/sample-stack-base:nanoserver-2022 + docker push cnbs/sample-stack-run:nanoserver-2022 + docker push cnbs/sample-stack-build:nanoserver-2022 deploy-windows-stacks-dotnet-framework-2022: @echo "> Deploying 'dotnet-framework-2022' stack..." docker push cnbs/sample-stack-run:dotnet-framework-2022 docker push cnbs/sample-stack-build:dotnet-framework-2022 -deploy-windows-builders-1809: deploy-windows-builders-nanoserver-1809 deploy-windows-builders-dotnet-framework-1809 - -deploy-windows-builders-2022: deploy-windows-builders-dotnet-framework-2022 +deploy-windows-builders-2022: deploy-windows-builders-dotnet-framework-2022 deploy-windows-builders-nanoserver-2022 -deploy-windows-builders-nanoserver-1809: - @echo "> Deploying 'nanoserver-1809' builder..." - docker push cnbs/sample-builder:nanoserver-1809 - -deploy-windows-builders-dotnet-framework-1809: - @echo "> Deploying 'dotnet-framework-1809' builder..." - docker push cnbs/sample-builder:dotnet-framework-1809 +deploy-windows-builders-nanoserver-2022: + @echo "> Deploying 'nanoserver-2022' builder..." + docker push cnbs/sample-builder:nanoserver-2022 deploy-windows-builders-dotnet-framework-2022: @echo "> Deploying 'dotnet-framework-2022' builder..." docker push cnbs/sample-builder:dotnet-framework-2022 clean-windows: - @echo "> Removing 'nanoserver-1809' stack..." - docker rmi cnbs/sample-stack-base:nanoserver-1809 || true - docker rmi cnbs/sample-stack-run:nanoserver-1809 || true - docker rmi cnbs/sample-stack-build:nanoserver-1809 || true - - @echo "> Removing 'dotnet-framework-1809' stack..." - docker rmi cnbs/sample-stack-run:dotnet-framework-1809 || true - docker rmi cnbs/sample-stack-build:dotnet-framework-1809 || true + @echo "> Removing 'nanoserver-2022' stack..." + docker rmi cnbs/sample-stack-base:nanoserver-2022 || true + docker rmi cnbs/sample-stack-run:nanoserver-2022 || true + docker rmi cnbs/sample-stack-build:nanoserver-2022 || true @echo "> Removing 'dotnet-framework-2022' stack..." docker rmi cnbs/sample-stack-run:dotnet-framework-2022 || true docker rmi cnbs/sample-stack-build:dotnet-framework-2022 || true @echo "> Removing builders..." - docker rmi cnbs/sample-builder:nanoserver-1809 || true - docker rmi cnbs/sample-builder:dotnet-framework-1809 || true + docker rmi cnbs/sample-builder:nanoserver-2022 || true docker rmi cnbs/sample-builder:dotnet-framework-2022 || true - @echo "> Removing 'nanoserver-1809' apps..." - docker rmi sample-hello-moon-windows-app:nanoserver-1809 || true - docker rmi sample-hello-world-windows-app:nanoserver-1809 || true - docker rmi sample-batch-script-app:nanoserver-1809 || true - - @echo "> Removing 'dotnet-framework-1809' apps..." - docker rmi sample-aspnet-app:dotnet-framework-1809 || true + @echo "> Removing 'nanoserver-2022' apps..." + docker rmi sample-hello-moon-windows-app:nanoserver-2022 || true + docker rmi sample-hello-world-windows-app:nanoserver-2022 || true + docker rmi sample-batch-script-app:nanoserver-2022 || true @echo "> Removing 'dotnet-framework-2022' apps..." docker rmi sample-aspnet-app:dotnet-framework-2022 || true diff --git a/apps/batch-script/README.md b/apps/batch-script/README.md index 88945c0f..17e96388 100644 --- a/apps/batch-script/README.md +++ b/apps/batch-script/README.md @@ -5,7 +5,7 @@ A runnable sample app demonstrating the usage of [project descriptor](https://gi ### Usage ```bash -pack build sample-batch-script-app --builder cnbs/sample-builder:nanoserver-1809 --trust-builder +pack build sample-batch-script-app --builder cnbs/sample-builder:nanoserver-2022 --trust-builder ``` ### Extended Functionality diff --git a/apps/batch-script/batch-script-buildpack/buildpack.toml b/apps/batch-script/batch-script-buildpack/buildpack.toml index 5a6a452a..e8602327 100644 --- a/apps/batch-script/batch-script-buildpack/buildpack.toml +++ b/apps/batch-script/batch-script-buildpack/buildpack.toml @@ -9,4 +9,4 @@ name = "Batch Script Buildpack" # Stacks that the buildpack will work with [[stacks]] -id = "io.buildpacks.samples.stacks.nanoserver-1809" +id = "io.buildpacks.samples.stacks.nanoserver-2022" diff --git a/builders/dotnet-framework-1809/README.md b/builders/dotnet-framework-1809/README.md deleted file mode 100644 index b1651b5c..00000000 --- a/builders/dotnet-framework-1809/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Sample .NET Framework 1809 Builder - -### Prerequisites -* Docker with Windows Containers and support for 1809 images - -### Usage - -#### Creating the builder - -```bash -pack builder create cnbs/sample-builder:dotnet-framework-1809 --config builder.toml -``` - -#### Build app with builder - -```bash -pack build sample-app --builder cnbs/sample-builder:dotnet-framework-1809 --trust-builder --path ../../apps/aspnet -``` - -#### Run built app -``` -docker run --rm -it -p 8080:80 sample-app -``` diff --git a/builders/dotnet-framework-1809/builder.toml b/builders/dotnet-framework-1809/builder.toml deleted file mode 100644 index eac86b5b..00000000 --- a/builders/dotnet-framework-1809/builder.toml +++ /dev/null @@ -1,17 +0,0 @@ -# Buildpacks to include in builder -[[buildpacks]] -id = "samples/dotnet-framework" -version = "0.0.1" -uri = "../../buildpacks/dotnet-framework" - -# Order used for detection -[[order]] -[[order.group]] -id = "samples/dotnet-framework" -version = "0.0.1" - -# Stack that will be used by the builder -[stack] -id = "io.buildpacks.samples.stacks.dotnet-framework-1809" -run-image = "cnbs/sample-stack-run:dotnet-framework-1809" -build-image = "cnbs/sample-stack-build:dotnet-framework-1809" \ No newline at end of file diff --git a/builders/nanoserver-1809/README.md b/builders/nanoserver-1809/README.md deleted file mode 100644 index 59fcd93c..00000000 --- a/builders/nanoserver-1809/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Sample Nanoserver 1809 Builder - -### Prerequisites -* Docker with Windows Containers and support for 1809 images - -### Usage - -#### Creating the builder - -```bash -pack builder create cnbs/sample-builder:nanoserver-1809 --config builder.toml -``` - -#### Build app with builder - -```bash -pack build sample-app --builder cnbs/sample-builder:nanoserver-1809 --path ../../apps/batch-script/ --trust-builder -``` - -_After building the app you should be able to simply run it via `docker run sample-app` -and see an Buildpacks.io ASCII banner._ diff --git a/builders/nanoserver-2022/README.md b/builders/nanoserver-2022/README.md new file mode 100644 index 00000000..1cb07be8 --- /dev/null +++ b/builders/nanoserver-2022/README.md @@ -0,0 +1,21 @@ +# Sample Nanoserver 2022 Builder + +### Prerequisites +* Docker with Windows Containers and support for 2022 images + +### Usage + +#### Creating the builder + +```bash +pack builder create cnbs/sample-builder:nanoserver-2022 --config builder.toml +``` + +#### Build app with builder + +```bash +pack build sample-app --builder cnbs/sample-builder:nanoserver-2022 --path ../../apps/batch-script/ --trust-builder +``` + +_After building the app you should be able to simply run it via `docker run sample-app` +and see an Buildpacks.io ASCII banner._ diff --git a/builders/nanoserver-1809/builder.toml b/builders/nanoserver-2022/builder.toml similarity index 62% rename from builders/nanoserver-1809/builder.toml rename to builders/nanoserver-2022/builder.toml index 7cb9230a..0d276145 100644 --- a/builders/nanoserver-1809/builder.toml +++ b/builders/nanoserver-2022/builder.toml @@ -10,6 +10,6 @@ version = "0.0.1" # Stack that will be used by the builder [stack] -id = "io.buildpacks.samples.stacks.nanoserver-1809" -run-image = "cnbs/sample-stack-run:nanoserver-1809" -build-image = "cnbs/sample-stack-build:nanoserver-1809" +id = "io.buildpacks.samples.stacks.nanoserver-2022" +run-image = "cnbs/sample-stack-run:nanoserver-2022" +build-image = "cnbs/sample-stack-build:nanoserver-2022" diff --git a/buildpacks/dotnet-framework/buildpack.toml b/buildpacks/dotnet-framework/buildpack.toml index 275f967f..8a539c22 100755 --- a/buildpacks/dotnet-framework/buildpack.toml +++ b/buildpacks/dotnet-framework/buildpack.toml @@ -6,7 +6,7 @@ api = "0.9" name = "Sample .NET Framework Buildpack" [[stacks]] - id = "io.buildpacks.samples.stacks.dotnet-framework-1809" + id = "io.buildpacks.samples.stacks.dotnet-framework-2022" [[stacks]] id = "io.buildpacks.samples.stacks.dotnet-framework-2022" diff --git a/buildpacks/hello-moon-windows/buildpack.toml b/buildpacks/hello-moon-windows/buildpack.toml index 49646537..216beeb2 100644 --- a/buildpacks/hello-moon-windows/buildpack.toml +++ b/buildpacks/hello-moon-windows/buildpack.toml @@ -10,10 +10,7 @@ homepage = "https://github.com/buildpacks/samples/tree/main/buildpacks/hello-moo # Stacks that the buildpack will work with [[stacks]] -id = "io.buildpacks.samples.stacks.nanoserver-1809" - -[[stacks]] -id = "io.buildpacks.samples.stacks.dotnet-framework-1809" +id = "io.buildpacks.samples.stacks.nanoserver-2022" [[stacks]] id = "io.buildpacks.samples.stacks.dotnet-framework-2022" diff --git a/buildpacks/hello-universe-windows/README.md b/buildpacks/hello-universe-windows/README.md index 3b1a2dd9..f409c379 100644 --- a/buildpacks/hello-universe-windows/README.md +++ b/buildpacks/hello-universe-windows/README.md @@ -6,7 +6,7 @@ A no-op meta-buildpack whose intent is to show how meta-buildpacks are construct ```bash pack build sample-hello-universe-windows-app \ - --builder cnbs/sample-builder:nanoserver-1809 \ + --builder cnbs/sample-builder:nanoserver-2022 \ --buildpack . \ --buildpack ../hello-world-windows/ \ --buildpack ../hello-moon-windows/ diff --git a/buildpacks/hello-world-windows/README.md b/buildpacks/hello-world-windows/README.md index 4d80f055..1554bbee 100644 --- a/buildpacks/hello-world-windows/README.md +++ b/buildpacks/hello-world-windows/README.md @@ -3,12 +3,12 @@ A no-op buildpack whose intent is to show minimal requirements of a buildpack on Windows. ### Prerequisites -* Docker with Windows Containers and support for 1809 images +* Docker with Windows Containers and support for 2022 images ### Usage ```bash -pack build sample-hello-world-windows-app --builder cnbs/sample-builder:nanoserver-1809 --buildpack . --trust-builder +pack build sample-hello-world-windows-app --builder cnbs/sample-builder:nanoserver-2022 --buildpack . --trust-builder ``` THEN diff --git a/buildpacks/hello-world-windows/buildpack.toml b/buildpacks/hello-world-windows/buildpack.toml index 161b9d6c..33337eab 100644 --- a/buildpacks/hello-world-windows/buildpack.toml +++ b/buildpacks/hello-world-windows/buildpack.toml @@ -9,7 +9,7 @@ name = "Hello World Buildpack" homepage = "https://github.com/buildpacks/samples/tree/main/buildpacks/hello-world-windows" [[stacks]] -id = "io.buildpacks.samples.stacks.nanoserver-1809" +id = "io.buildpacks.samples.stacks.nanoserver-2022" [[stacks]] id = "io.buildpacks.samples.stacks.dotnet-framework-2022" diff --git a/stacks/dotnet-framework-1809/build/Dockerfile b/stacks/dotnet-framework-1809/build/Dockerfile deleted file mode 100644 index 7edd79da..00000000 --- a/stacks/dotnet-framework-1809/build/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 - -ARG stack_id - -# non-zero sets all user-owned directories to BUILTIN\Users -ARG cnb_uid=1 -ARG cnb_gid=1 - -ENV CNB_USER_ID=${cnb_uid} -ENV CNB_GROUP_ID=${cnb_gid} - -LABEL io.buildpacks.stack.id=${stack_id} -ENV CNB_STACK_ID=${stack_id} - -USER ContainerAdministrator diff --git a/stacks/dotnet-framework-1809/run/Dockerfile b/stacks/dotnet-framework-1809/run/Dockerfile deleted file mode 100644 index 90429a45..00000000 --- a/stacks/dotnet-framework-1809/run/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019 - -ARG stack_id - -# Create unresolved symlink from c:\inetpub\wwwroot to c:\workspace -RUN Remove-Item -Force -Recurse c:\inetpub\wwwroot ; New-Item -Type Directory c:\workspace ; New-Item -Type SymbolicLink -Path c:\inetpub\wwwroot -Value c:\workspace ; Remove-Item -Force c:\workspace - -# launcher requires a non-empty PATH to workaround https://github.com/buildpacks/pack/issues/800 -ENV PATH=C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Users\\ContainerAdministrator\\AppData\\Local\\Microsoft\\WindowsApps - -LABEL io.buildpacks.stack.id=${stack_id} - -USER ContainerAdministrator diff --git a/stacks/nanoserver-1809/base/Dockerfile b/stacks/nanoserver-2022/base/Dockerfile similarity index 85% rename from stacks/nanoserver-1809/base/Dockerfile rename to stacks/nanoserver-2022/base/Dockerfile index 2015cd91..02eef5c1 100755 --- a/stacks/nanoserver-1809/base/Dockerfile +++ b/stacks/nanoserver-2022/base/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/windows/nanoserver:1809 +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 # non-zero sets all user-owned directories to BUILTIN\Users ARG cnb_uid=1 diff --git a/stacks/nanoserver-1809/build/Dockerfile b/stacks/nanoserver-2022/build/Dockerfile similarity index 100% rename from stacks/nanoserver-1809/build/Dockerfile rename to stacks/nanoserver-2022/build/Dockerfile diff --git a/stacks/nanoserver-1809/run/Dockerfile b/stacks/nanoserver-2022/run/Dockerfile similarity index 100% rename from stacks/nanoserver-1809/run/Dockerfile rename to stacks/nanoserver-2022/run/Dockerfile From faec3075caf8dcb15446df1852190a39b6546c22 Mon Sep 17 00:00:00 2001 From: Natalie Arellano Date: Tue, 12 Sep 2023 08:29:58 -0700 Subject: [PATCH 2/3] Build nanoserver along with dotnet framework, so that it can be deployed later Signed-off-by: Natalie Arellano --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fdbd4f56..ef2c6914 100644 --- a/Makefile +++ b/Makefile @@ -155,7 +155,7 @@ set-experimental: ## Windows #################### -build-windows-2022: build-windows-packages build-dotnet-framework-2022 +build-windows-2022: build-windows-packages build-dotnet-framework-2022 build-nanoserver-2022 build-nanoserver-2022: build-stack-nanoserver-2022 build-builder-nanoserver-2022 build-buildpacks-nanoserver-2022 From e5136bfff561f102abe9c61b224bace5d41fb1f3 Mon Sep 17 00:00:00 2001 From: Natalie Arellano Date: Wed, 20 Sep 2023 11:27:01 -0400 Subject: [PATCH 3/3] Add targets and rename stack -> base image where appropriate Signed-off-by: Natalie Arellano --- .github/workflows/build-and-deploy.yml | 10 +- Makefile | 110 +++++++++--------- README.md | 2 +- .../bash-script-buildpack/buildpack.toml | 10 +- .../batch-script-buildpack/buildpack.toml | 8 +- {stacks => base-images}/README.md | 2 +- base-images/alpine/base/Dockerfile | 14 +++ base-images/alpine/build/Dockerfile | 25 ++++ .../alpine/build/bin/yj-linux | Bin base-images/alpine/run/Dockerfile | 11 ++ base-images/alpine/run/curl.Dockerfile | 22 ++++ base-images/build.sh | 106 +++++++++++++++++ .../dotnet-framework-2022/base/Dockerfile | 11 ++ .../dotnet-framework-2022/build/Dockerfile | 16 +++ .../dotnet-framework-2022/run/Dockerfile | 8 +- base-images/jammy/base/Dockerfile | 16 +++ base-images/jammy/build/Dockerfile | 26 +++++ .../jammy/build/bin/yj-linux | Bin base-images/jammy/run/Dockerfile | 11 ++ base-images/nanoserver-2022/base/Dockerfile | 14 +++ base-images/nanoserver-2022/build/Dockerfile | 16 +++ base-images/nanoserver-2022/run/Dockerfile | 5 + builders/README.md | 4 +- builders/alpine/builder.toml | 13 ++- builders/dotnet-framework-2022/builder.toml | 13 ++- builders/jammy/builder.toml | 13 ++- builders/nanoserver-2022/builder.toml | 13 ++- buildpacks/dotnet-framework/buildpack.toml | 18 ++- buildpacks/hello-extensions/buildpack.toml | 6 +- buildpacks/hello-moon-windows/buildpack.toml | 8 +- buildpacks/hello-moon/buildpack.toml | 16 +-- buildpacks/hello-processes/buildpack.toml | 15 +-- buildpacks/hello-world-windows/buildpack.toml | 9 +- buildpacks/hello-world/buildpack.toml | 15 +-- buildpacks/java-maven/buildpack.toml | 15 +-- buildpacks/kotlin-gradle/buildpack.toml | 14 +-- buildpacks/ruby-bundler/buildpack.toml | 11 +- stacks/alpine/base/Dockerfile | 15 --- stacks/alpine/build/Dockerfile | 16 --- stacks/alpine/run/Dockerfile | 9 -- stacks/alpine/run/curl.Dockerfile | 22 ---- stacks/build-stack.sh | 80 ------------- stacks/dotnet-framework-2022/build/Dockerfile | 15 --- stacks/jammy/base/Dockerfile | 17 --- stacks/jammy/build/Dockerfile | 17 --- stacks/jammy/run/Dockerfile | 9 -- stacks/nanoserver-2022/base/Dockerfile | 13 --- stacks/nanoserver-2022/build/Dockerfile | 8 -- stacks/nanoserver-2022/run/Dockerfile | 7 -- 49 files changed, 469 insertions(+), 385 deletions(-) rename {stacks => base-images}/README.md (87%) create mode 100755 base-images/alpine/base/Dockerfile create mode 100755 base-images/alpine/build/Dockerfile rename {stacks => base-images}/alpine/build/bin/yj-linux (100%) create mode 100755 base-images/alpine/run/Dockerfile create mode 100644 base-images/alpine/run/curl.Dockerfile create mode 100755 base-images/build.sh create mode 100644 base-images/dotnet-framework-2022/base/Dockerfile create mode 100644 base-images/dotnet-framework-2022/build/Dockerfile rename {stacks => base-images}/dotnet-framework-2022/run/Dockerfile (83%) create mode 100755 base-images/jammy/base/Dockerfile create mode 100755 base-images/jammy/build/Dockerfile rename {stacks => base-images}/jammy/build/bin/yj-linux (100%) create mode 100755 base-images/jammy/run/Dockerfile create mode 100755 base-images/nanoserver-2022/base/Dockerfile create mode 100755 base-images/nanoserver-2022/build/Dockerfile create mode 100755 base-images/nanoserver-2022/run/Dockerfile delete mode 100755 stacks/alpine/base/Dockerfile delete mode 100755 stacks/alpine/build/Dockerfile delete mode 100755 stacks/alpine/run/Dockerfile delete mode 100644 stacks/alpine/run/curl.Dockerfile delete mode 100755 stacks/build-stack.sh delete mode 100644 stacks/dotnet-framework-2022/build/Dockerfile delete mode 100755 stacks/jammy/base/Dockerfile delete mode 100755 stacks/jammy/build/Dockerfile delete mode 100755 stacks/jammy/run/Dockerfile delete mode 100755 stacks/nanoserver-2022/base/Dockerfile delete mode 100755 stacks/nanoserver-2022/build/Dockerfile delete mode 100755 stacks/nanoserver-2022/run/Dockerfile diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 3710cfe7..fc1c11b0 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -22,12 +22,12 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} result-encoding: string - # FIXME: Revert back to 'getLatestRelease' when pack v0.30.0 is released + # FIXME: Revert back to 'getLatestRelease' when pack v0.31.0 is released script: | return github.rest.repos.getReleaseByTag({ owner: "buildpacks", repo: "pack", - tag: "v0.30.0-rc1" + tag: "v0.31.0-rc1" }).then(result => { return result.data.assets .filter(a => a.name.includes("-linux.tgz")) @@ -68,10 +68,12 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} result-encoding: string + # FIXME: Revert back to 'getLatestRelease' when pack v0.31.0 is released script: | - return github.rest.repos.getLatestRelease({ + return github.rest.repos.getReleaseByTag({ owner: "buildpacks", - repo: "pack" + repo: "pack", + tag: "v0.31.0-rc1" }).then(result => { return result.data.assets .filter(a => a.name.includes("windows")) diff --git a/Makefile b/Makefile index ef2c6914..6cff0a0d 100644 --- a/Makefile +++ b/Makefile @@ -8,21 +8,21 @@ clean: clean-linux clean-windows ## Linux #################### -build-linux: build-linux-stacks build-linux-packages build-linux-builders build-linux-buildpacks +build-linux: build-linux-bases build-linux-packages build-linux-builders build-linux-buildpacks -build-linux-stacks: build-stack-alpine build-stack-jammy +build-linux-bases: build-base-alpine build-base-jammy -build-alpine: build-stack-alpine build-builder-alpine build-buildpacks-alpine +build-alpine: build-base-alpine build-builder-alpine build-buildpacks-alpine -build-jammy: build-stack-jammy build-builder-jammy build-buildpacks-jammy +build-jammy: build-base-jammy build-builder-jammy build-buildpacks-jammy -build-stack-alpine: - @echo "> Building 'alpine' stack..." - bash stacks/build-stack.sh stacks/alpine +build-base-alpine: + @echo "> Building 'alpine' base images..." + bash base-images/build.sh alpine -build-stack-jammy: - @echo "> Building 'jammy' stack..." - bash stacks/build-stack.sh stacks/jammy +build-base-jammy: + @echo "> Building 'jammy' base images..." + bash base-images/build.sh jammy build-linux-builders: build-builder-alpine build-builder-jammy @@ -84,18 +84,18 @@ build-linux-packages: build-sample-root @echo "> Creating 'hello-universe' buildpack package" $(PACK_CMD) buildpack package cnbs/sample-package:hello-universe --config $(SAMPLES_ROOT)/packages/hello-universe/package.toml $(PULL_POLICY_NEVER) -deploy-linux: deploy-linux-stacks deploy-linux-packages deploy-linux-builders +deploy-linux: deploy-linux-bases deploy-linux-packages deploy-linux-builders -deploy-linux-stacks: - @echo "> Deploying 'alpine' stack..." - docker push cnbs/sample-stack-base:alpine - docker push cnbs/sample-stack-run:alpine - docker push cnbs/sample-stack-build:alpine +deploy-linux-bases: + @echo "> Deploying 'alpine' base images..." + docker push cnbs/sample-base:alpine + docker push cnbs/sample-base-run:alpine + docker push cnbs/sample-base-build:alpine - @echo "> Deploying 'jammy' stack..." - docker push cnbs/sample-stack-base:jammy - docker push cnbs/sample-stack-run:jammy - docker push cnbs/sample-stack-build:jammy + @echo "> Deploying 'jammy' base images..." + docker push cnbs/sample-base:jammy + docker push cnbs/sample-base-run:jammy + docker push cnbs/sample-base-build:jammy deploy-linux-packages: @echo "> Deploying linux packages..." @@ -111,15 +111,15 @@ deploy-linux-builders: docker push cnbs/sample-builder:jammy clean-linux: - @echo "> Removing 'alpine' stack..." - docker rmi cnbs/sample-stack-base:alpine || true - docker rmi cnbs/sample-stack-run:alpine || true - docker rmi cnbs/sample-stack-build:alpine || true + @echo "> Removing 'alpine' base images..." + docker rmi cnbs/sample-base:alpine || true + docker rmi cnbs/sample-base-run:alpine || true + docker rmi cnbs/sample-base-build:alpine || true - @echo "> Removing 'jammy' stack..." - docker rmi cnbs/sample-stack-base:jammy || true - docker rmi cnbs/sample-stack-run:jammy || true - docker rmi cnbs/sample-stack-build:jammy || true + @echo "> Removing 'jammy' base images..." + docker rmi cnbs/sample-base:jammy || true + docker rmi cnbs/sample-base-run:jammy || true + docker rmi cnbs/sample-base-build:jammy || true @echo "> Removing builders..." docker rmi cnbs/sample-builder:alpine || true @@ -157,17 +157,17 @@ set-experimental: build-windows-2022: build-windows-packages build-dotnet-framework-2022 build-nanoserver-2022 -build-nanoserver-2022: build-stack-nanoserver-2022 build-builder-nanoserver-2022 build-buildpacks-nanoserver-2022 +build-nanoserver-2022: build-base-nanoserver-2022 build-builder-nanoserver-2022 build-buildpacks-nanoserver-2022 -build-dotnet-framework-2022: build-stack-dotnet-framework-2022 build-builder-dotnet-framework-2022 build-buildpacks-dotnet-framework-2022 +build-dotnet-framework-2022: build-base-dotnet-framework-2022 build-builder-dotnet-framework-2022 build-buildpacks-dotnet-framework-2022 -build-stack-nanoserver-2022: - @echo "> Building 'nanoserver-2022' stack..." - bash stacks/build-stack.sh stacks/nanoserver-2022 +build-base-nanoserver-2022: + @echo "> Building 'nanoserver-2022' base images..." + bash base-images/build.sh nanoserver-2022 -build-stack-dotnet-framework-2022: - @echo "> Building 'dotnet-framework-2022' stack..." - bash stacks/build-stack.sh stacks/dotnet-framework-2022 +build-base-dotnet-framework-2022: + @echo "> Building 'dotnet-framework-2022' base images..." + bash base-images/build.sh dotnet-framework-2022 build-builder-nanoserver-2022: build-windows-packages @echo "> Building 'nanoserver-2022' builder..." @@ -200,20 +200,20 @@ deploy-windows-packages: docker push cnbs/sample-package:hello-world-windows docker push cnbs/sample-package:hello-universe-windows -deploy-windows-2022: deploy-windows-stacks-2022 deploy-windows-builders-2022 +deploy-windows-2022: deploy-windows-bases-2022 deploy-windows-builders-2022 -deploy-windows-stacks-2022: deploy-windows-stacks-dotnet-framework-2022 deploy-windows-stacks-nanoserver-2022 +deploy-windows-bases-2022: deploy-windows-bases-dotnet-framework-2022 deploy-windows-bases-nanoserver-2022 -deploy-windows-stacks-nanoserver-2022: - @echo "> Deploying 'nanoserver-2022' stack..." - docker push cnbs/sample-stack-base:nanoserver-2022 - docker push cnbs/sample-stack-run:nanoserver-2022 - docker push cnbs/sample-stack-build:nanoserver-2022 +deploy-windows-bases-nanoserver-2022: + @echo "> Deploying 'nanoserver-2022' base images..." + docker push cnbs/sample-base:nanoserver-2022 + docker push cnbs/sample-base-run:nanoserver-2022 + docker push cnbs/sample-base-build:nanoserver-2022 -deploy-windows-stacks-dotnet-framework-2022: - @echo "> Deploying 'dotnet-framework-2022' stack..." - docker push cnbs/sample-stack-run:dotnet-framework-2022 - docker push cnbs/sample-stack-build:dotnet-framework-2022 +deploy-windows-bases-dotnet-framework-2022: + @echo "> Deploying 'dotnet-framework-2022' base images..." + docker push cnbs/sample-base-run:dotnet-framework-2022 + docker push cnbs/sample-base-build:dotnet-framework-2022 deploy-windows-builders-2022: deploy-windows-builders-dotnet-framework-2022 deploy-windows-builders-nanoserver-2022 @@ -226,14 +226,14 @@ deploy-windows-builders-dotnet-framework-2022: docker push cnbs/sample-builder:dotnet-framework-2022 clean-windows: - @echo "> Removing 'nanoserver-2022' stack..." - docker rmi cnbs/sample-stack-base:nanoserver-2022 || true - docker rmi cnbs/sample-stack-run:nanoserver-2022 || true - docker rmi cnbs/sample-stack-build:nanoserver-2022 || true - - @echo "> Removing 'dotnet-framework-2022' stack..." - docker rmi cnbs/sample-stack-run:dotnet-framework-2022 || true - docker rmi cnbs/sample-stack-build:dotnet-framework-2022 || true + @echo "> Removing 'nanoserver-2022' base images..." + docker rmi cnbs/sample-base:nanoserver-2022 || true + docker rmi cnbs/sample-base-run:nanoserver-2022 || true + docker rmi cnbs/sample-base-build:nanoserver-2022 || true + + @echo "> Removing 'dotnet-framework-2022' base images..." + docker rmi cnbs/sample-base-run:dotnet-framework-2022 || true + docker rmi cnbs/sample-base-build:dotnet-framework-2022 || true @echo "> Removing builders..." docker rmi cnbs/sample-builder:nanoserver-2022 || true diff --git a/README.md b/README.md index 4ffef4e8..3f377d3f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Includes: - [Apps](apps/) - [Buildpacks](buildpacks/) - [Builders](builders/) -- [Stacks](stacks/) +- [Base Images](base-images/) - [Packages](packages/) diff --git a/apps/bash-script/bash-script-buildpack/buildpack.toml b/apps/bash-script/bash-script-buildpack/buildpack.toml index dc81cd4d..b66ba902 100644 --- a/apps/bash-script/bash-script-buildpack/buildpack.toml +++ b/apps/bash-script/bash-script-buildpack/buildpack.toml @@ -7,12 +7,6 @@ id = "samples/bash-script" version = "0.0.1" name = "Bash Script Buildpack" -# Stacks that the buildpack will work with +# Stacks (deprecated) the buildpack will work with [[stacks]] -id = "io.buildpacks.samples.stacks.jammy" - -[[stacks]] -id = "io.buildpacks.samples.stacks.alpine" - -[[stacks]] -id = "io.buildpacks.stacks.jammy" \ No newline at end of file +id = "*" diff --git a/apps/batch-script/batch-script-buildpack/buildpack.toml b/apps/batch-script/batch-script-buildpack/buildpack.toml index e8602327..82dc3770 100644 --- a/apps/batch-script/batch-script-buildpack/buildpack.toml +++ b/apps/batch-script/batch-script-buildpack/buildpack.toml @@ -7,6 +7,12 @@ id = "samples/batch-script" version = "0.0.1" name = "Batch Script Buildpack" -# Stacks that the buildpack will work with +# Targets the buildpack will work with +[[targets]] +os = "windows" +[[targets.distros]] +version = "10.0.20348.1906" + +# Stacks (deprecated) the buildpack will work with [[stacks]] id = "io.buildpacks.samples.stacks.nanoserver-2022" diff --git a/stacks/README.md b/base-images/README.md similarity index 87% rename from stacks/README.md rename to base-images/README.md index 2271b144..2f9788d1 100755 --- a/stacks/README.md +++ b/base-images/README.md @@ -9,7 +9,7 @@ To build the stack use the `./build-stack` script: ```text Usage: ./stacks/build-stack.sh [-f ] [-p ] - -f prefix to use for images (default: cnbs/sample-stack) + -f prefix to use for images (default: cnbs/sample-base) -p prefix to use for images (default: amd64) directory of stack to build ``` diff --git a/base-images/alpine/base/Dockerfile b/base-images/alpine/base/Dockerfile new file mode 100755 index 00000000..11f61992 --- /dev/null +++ b/base-images/alpine/base/Dockerfile @@ -0,0 +1,14 @@ +FROM alpine:3 + +# Install packages that we want to make available at both build and run time +RUN apk add --update --no-cache bash ca-certificates + +# Set required CNB target information +ARG distro_name +LABEL io.buildpacks.base.distro.name=${distro_name} +ARG distro_version +LABEL io.buildpacks.base.distro.version=${distro_version} + +# Set deprecated CNB stack information (see https://buildpacks.io/docs/reference/spec/migration/platform-api-0.11-0.12/#stacks-are-deprecated-1) +ARG stack_id +LABEL io.buildpacks.stack.id="${stack_id}" diff --git a/base-images/alpine/build/Dockerfile b/base-images/alpine/build/Dockerfile new file mode 100755 index 00000000..2066087c --- /dev/null +++ b/base-images/alpine/build/Dockerfile @@ -0,0 +1,25 @@ +ARG base_image +FROM ${base_image} + +# Install packages that we want to make available at build time +RUN apk add --update ca-certificates git jq wget && \ + rm -rf /var/cache/apk/* + +COPY ./bin/yj-linux /usr/local/bin/yj + +# Create user and group +ARG cnb_uid=1000 +ARG cnb_gid=1001 +RUN addgroup -g ${cnb_gid} cnb && \ + adduser -u ${cnb_uid} -G cnb -s /bin/bash -D cnb + +# Set user and group +USER ${cnb_uid}:${cnb_gid} + +# Set required CNB user information +ENV CNB_USER_ID=${cnb_uid} +ENV CNB_GROUP_ID=${cnb_gid} + +# Set deprecated CNB stack information (see https://buildpacks.io/docs/reference/spec/migration/platform-api-0.11-0.12/#stacks-are-deprecated-1) +ARG stack_id +ENV CNB_STACK_ID=${stack_id} diff --git a/stacks/alpine/build/bin/yj-linux b/base-images/alpine/build/bin/yj-linux similarity index 100% rename from stacks/alpine/build/bin/yj-linux rename to base-images/alpine/build/bin/yj-linux diff --git a/base-images/alpine/run/Dockerfile b/base-images/alpine/run/Dockerfile new file mode 100755 index 00000000..29da3c91 --- /dev/null +++ b/base-images/alpine/run/Dockerfile @@ -0,0 +1,11 @@ +ARG base_image +FROM ${base_image} + +# Create user and group +ARG cnb_uid=1000 +ARG cnb_gid=1001 +RUN addgroup -g ${cnb_gid} cnb && \ + adduser -u ${cnb_uid} -G cnb -s /bin/bash -D cnb + +# Set user and group +USER ${cnb_uid}:${cnb_gid} diff --git a/base-images/alpine/run/curl.Dockerfile b/base-images/alpine/run/curl.Dockerfile new file mode 100644 index 00000000..2c6e413d --- /dev/null +++ b/base-images/alpine/run/curl.Dockerfile @@ -0,0 +1,22 @@ +FROM curlimages/curl + +COPY ./Dockerfile /home/curl_user/Dockerfile + +RUN curl --version + +# Create user and group +ARG cnb_uid=1000 +ARG cnb_gid=1001 +USER root +RUN addgroup -g ${cnb_gid} cnb && \ + adduser -u ${cnb_uid} -G cnb -s /bin/bash -D cnb + +# Set user and group +USER ${cnb_uid}:${cnb_gid} + +# Set required CNB target information +LABEL io.buildpacks.base.distro.name=alpine +LABEL io.buildpacks.base.distro.version=3.18.2 + +# Set deprecated CNB stack information (see https://buildpacks.io/docs/reference/spec/migration/platform-api-0.11-0.12/#stacks-are-deprecated-1) +LABEL io.buildpacks.stack.id=io.buildpacks.samples.stacks.alpine diff --git a/base-images/build.sh b/base-images/build.sh new file mode 100755 index 00000000..5203c491 --- /dev/null +++ b/base-images/build.sh @@ -0,0 +1,106 @@ +#!/usr/bin/env bash +set -e + +ID_PREFIX="io.buildpacks.samples.stacks" + +DEFAULT_PREFIX=cnbs/sample-base +DEFAULT_PLATFORM=amd64 + +REPO_PREFIX=${DEFAULT_PREFIX} +PLATFORM=${DEFAULT_PLATFORM} + +usage() { + echo "Usage: " + echo " $0 [-f ] [-p ] " + echo " -f prefix to use for images (default: ${DEFAULT_PREFIX})" + echo " -p prefix to use for images (default: ${DEFAULT_PLATFORM})" + echo " directory to build" + exit 1; +} + +while getopts "v:p:" o; do + case "${o}" in + f) + REPO_PREFIX=${OPTARG} + ;; + p) + PLATFORM=${OPTARG} + ;; + \?) + echo "Invalid option: -$OPTARG" 1>&2 + usage + ;; + :) + usage + ;; + esac +done + +BASE_DIR=${@:$OPTIND:1} + +if [[ -z ${REPO_PREFIX} ]]; then + echo "Prefix cannot be empty" + echo + usage + exit 1 +fi + +if [[ -z ${BASE_DIR} ]]; then + echo "Must specify directory" + echo + usage + exit 1 +fi + +cd $(dirname $0) + +IMAGE_DIR=$(realpath "${BASE_DIR}") +TAG=$(basename "${IMAGE_DIR}") +STACK_ID="${ID_PREFIX}.$(basename "${IMAGE_DIR}")" +BASE_IMAGE=${REPO_PREFIX}:${TAG} +RUN_IMAGE=${REPO_PREFIX}-run:${TAG} +BUILD_IMAGE=${REPO_PREFIX}-build:${TAG} +FROM_IMAGE=$(head -n1 "${IMAGE_DIR}"/base/Dockerfile | cut -d' ' -f2) + +# Get target distro information +if cmd /c ver; then +DISTRO_NAME="" +RAW_VERSION=$(docker run --rm "${FROM_IMAGE}" cmd /c ver) +DISTRO_VERSION=$(echo "$RAW_VERSION" | head -n1 | sed 's/Microsoft Windows //' | sed 's/[][]//g' | cut -d' ' -f2) +echo "DISTRO_VERSION: ${DISTRO_VERSION}" +else +DISTRO_NAME=$(docker run --rm "${FROM_IMAGE}" cat /etc/os-release | grep '^ID=' | cut -d'=' -f2) +echo "DISTRO_NAME: ${DISTRO_NAME}" +DISTRO_VERSION=$(docker run --rm "${FROM_IMAGE}" cat /etc/os-release | grep '^VERSION_ID=' | cut -d'=' -f2) +echo "DISTRO_VERSION: ${DISTRO_VERSION}" +fi + +if [[ -d "${IMAGE_DIR}/base" ]]; then + docker build --platform=${PLATFORM} \ + --build-arg "distro_name=${DISTRO_NAME}" \ + --build-arg "distro_version=${DISTRO_VERSION}" \ + --build-arg "stack_id=${STACK_ID}" \ + -t "${BASE_IMAGE}" \ + "${IMAGE_DIR}/base" +fi + +echo "BUILDING ${BUILD_IMAGE}..." +docker build --platform=${PLATFORM} \ + --build-arg "base_image=${BASE_IMAGE}" \ + --build-arg "stack_id=${STACK_ID}" \ + -t "${BUILD_IMAGE}" \ + "${IMAGE_DIR}/build" + +echo "BUILDING ${RUN_IMAGE}..." +docker build --platform=${PLATFORM} \ + --build-arg "base_image=${BASE_IMAGE}" \ + -t "${RUN_IMAGE}" \ + "${IMAGE_DIR}/run" + +echo +echo "BASE IMAGES BUILT!" +echo +echo "Images:" +for IMAGE in "${BASE_IMAGE}" "${BUILD_IMAGE}" "${RUN_IMAGE}"; do + echo " ${IMAGE}" +done \ No newline at end of file diff --git a/base-images/dotnet-framework-2022/base/Dockerfile b/base-images/dotnet-framework-2022/base/Dockerfile new file mode 100644 index 00000000..22232b77 --- /dev/null +++ b/base-images/dotnet-framework-2022/base/Dockerfile @@ -0,0 +1,11 @@ +FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022 + +# Set required CNB target information +ARG distro_name +LABEL io.buildpacks.base.distro.name=${distro_name} +ARG distro_version +LABEL io.buildpacks.base.distro.version=${distro_version} + +# Set deprecated CNB stack information (see https://buildpacks.io/docs/reference/spec/migration/platform-api-0.11-0.12/#stacks-are-deprecated-1) +ARG stack_id +LABEL io.buildpacks.stack.id=${stack_id} diff --git a/base-images/dotnet-framework-2022/build/Dockerfile b/base-images/dotnet-framework-2022/build/Dockerfile new file mode 100644 index 00000000..a24970e0 --- /dev/null +++ b/base-images/dotnet-framework-2022/build/Dockerfile @@ -0,0 +1,16 @@ +ARG base_image +FROM ${base_image} + +# Set user +USER ContainerAdministrator + +# Set required CNB user information +ARG cnb_uid=1 +ARG cnb_gid=1 +# non-zero sets all user-owned directories to BUILTIN\Users +ENV CNB_USER_ID=${cnb_uid} +ENV CNB_GROUP_ID=${cnb_gid} + +# Set deprecated CNB stack information (see https://buildpacks.io/docs/reference/spec/migration/platform-api-0.11-0.12/#stacks-are-deprecated-1) +ARG stack_id +ENV CNB_STACK_ID=${stack_id} diff --git a/stacks/dotnet-framework-2022/run/Dockerfile b/base-images/dotnet-framework-2022/run/Dockerfile similarity index 83% rename from stacks/dotnet-framework-2022/run/Dockerfile rename to base-images/dotnet-framework-2022/run/Dockerfile index eb9dbe87..86e23289 100644 --- a/stacks/dotnet-framework-2022/run/Dockerfile +++ b/base-images/dotnet-framework-2022/run/Dockerfile @@ -1,6 +1,5 @@ -FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2022 - -ARG stack_id +ARG base_image +FROM ${base_image} # Create unresolved symlink from c:\inetpub\wwwroot to c:\workspace RUN powershell -Command \ @@ -12,6 +11,5 @@ RUN powershell -Command \ # launcher requires a non-empty PATH to workaround https://github.com/buildpacks/pack/issues/800 ENV PATH=C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Users\\ContainerAdministrator\\AppData\\Local\\Microsoft\\WindowsApps -LABEL io.buildpacks.stack.id=${stack_id} - +# Set user USER ContainerAdministrator diff --git a/base-images/jammy/base/Dockerfile b/base-images/jammy/base/Dockerfile new file mode 100755 index 00000000..832f39e7 --- /dev/null +++ b/base-images/jammy/base/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:jammy + +# Install packages that we want to make available at both build and run time +RUN apt update && \ + apt install -y xz-utils ca-certificates libyaml-0-2 && \ + rm -rf /var/lib/apt/lists/* + +# Set required CNB target information +ARG distro_name +LABEL io.buildpacks.base.distro.name=${distro_name} +ARG distro_version +LABEL io.buildpacks.base.distro.version=${distro_version} + +# Set deprecated CNB stack information (see https://buildpacks.io/docs/reference/spec/migration/platform-api-0.11-0.12/#stacks-are-deprecated-1) +ARG stack_id +LABEL io.buildpacks.stack.id=${stack_id} diff --git a/base-images/jammy/build/Dockerfile b/base-images/jammy/build/Dockerfile new file mode 100755 index 00000000..f63d9f3a --- /dev/null +++ b/base-images/jammy/build/Dockerfile @@ -0,0 +1,26 @@ +ARG base_image +FROM ${base_image} + +# Install packages that we want to make available at build time +RUN apt update && \ + apt install -y git wget jq && \ + rm -rf /var/lib/apt/lists/* + +COPY ./bin/yj-linux /usr/local/bin/yj + +# Create user and group +ARG cnb_uid=1000 +ARG cnb_gid=1000 +RUN groupadd cnb --gid ${cnb_gid} && \ + useradd --uid ${cnb_uid} --gid ${cnb_gid} -m -s /bin/bash cnb + +# Set user and group +USER ${cnb_uid}:${cnb_gid} + +# Set required CNB information +ENV CNB_USER_ID=${cnb_uid} +ENV CNB_GROUP_ID=${cnb_gid} + +# Set deprecated CNB stack information (see https://buildpacks.io/docs/reference/spec/migration/platform-api-0.11-0.12/#stacks-are-deprecated-1) +ARG stack_id +ENV CNB_STACK_ID=${stack_id} diff --git a/stacks/jammy/build/bin/yj-linux b/base-images/jammy/build/bin/yj-linux similarity index 100% rename from stacks/jammy/build/bin/yj-linux rename to base-images/jammy/build/bin/yj-linux diff --git a/base-images/jammy/run/Dockerfile b/base-images/jammy/run/Dockerfile new file mode 100755 index 00000000..02376f0b --- /dev/null +++ b/base-images/jammy/run/Dockerfile @@ -0,0 +1,11 @@ +ARG base_image +FROM ${base_image} + +# Create user and group +ARG cnb_uid=1000 +ARG cnb_gid=1000 +RUN groupadd cnb --gid ${cnb_gid} && \ + useradd --uid ${cnb_uid} --gid ${cnb_gid} -m -s /bin/bash cnb + +# Set user and group +USER ${cnb_uid}:${cnb_gid} diff --git a/base-images/nanoserver-2022/base/Dockerfile b/base-images/nanoserver-2022/base/Dockerfile new file mode 100755 index 00000000..6a3b2887 --- /dev/null +++ b/base-images/nanoserver-2022/base/Dockerfile @@ -0,0 +1,14 @@ +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +# launcher requires a non-empty PATH to workaround https://github.com/buildpacks/pack/issues/800 +ENV PATH c:\\Windows\\system32;C:\\Windows + +# Set required CNB target information +ARG distro_name +LABEL io.buildpacks.base.distro.name=${distro_name} +ARG distro_version +LABEL io.buildpacks.base.distro.version=${distro_version} + +# Set deprecated CNB stack information (see https://buildpacks.io/docs/reference/spec/migration/platform-api-0.11-0.12/#stacks-are-deprecated-1) +ARG stack_id +LABEL io.buildpacks.stack.id=${stack_id} diff --git a/base-images/nanoserver-2022/build/Dockerfile b/base-images/nanoserver-2022/build/Dockerfile new file mode 100755 index 00000000..c3ca8d6c --- /dev/null +++ b/base-images/nanoserver-2022/build/Dockerfile @@ -0,0 +1,16 @@ +ARG base_image +FROM ${base_image} + +# Set user +USER ContainerUser + +# Set required CNB user information +ARG cnb_uid=1 +ARG cnb_gid=1 +# non-zero sets all user-owned directories to BUILTIN\Users +ENV CNB_USER_ID=${cnb_uid} +ENV CNB_GROUP_ID=${cnb_gid} + +# Set deprecated CNB stack information (see https://buildpacks.io/docs/reference/spec/migration/platform-api-0.11-0.12/#stacks-are-deprecated-1) +ARG stack_id +ENV CNB_STACK_ID=${stack_id} diff --git a/base-images/nanoserver-2022/run/Dockerfile b/base-images/nanoserver-2022/run/Dockerfile new file mode 100755 index 00000000..51505061 --- /dev/null +++ b/base-images/nanoserver-2022/run/Dockerfile @@ -0,0 +1,5 @@ +ARG base_image +FROM ${base_image} + +# Set user +USER ContainerUser diff --git a/builders/README.md b/builders/README.md index 501be4a9..56c38231 100644 --- a/builders/README.md +++ b/builders/README.md @@ -1,6 +1,6 @@ # Sample Builders -A sample of builders that use the [stacks](../stacks/) in this repo. +A sample of builders that use the [base images](../base-images/) in this repo. ### Contains: - [Alpine](alpine/) @@ -13,5 +13,5 @@ A sample of builders that use the [stacks](../stacks/) in this repo. ### What's next? Is that all? If you want to dive deeper, there are two final components you might want to learn about: -- [Stacks](../stacks) marry the build-time and run-time environments for your code in the form of images under a common id. +- [Base Images](../base-images) provide the build-time and run-time environments for your code. - [Buildpackages](../packages) allow easy distribution of buildpacks in image registries and simplify configuration and composition of builders and "meta" buildpacks. diff --git a/builders/alpine/builder.toml b/builders/alpine/builder.toml index b5029fbb..9a080548 100644 --- a/builders/alpine/builder.toml +++ b/builders/alpine/builder.toml @@ -68,8 +68,15 @@ version = "0.0.1" id = "samples/cowsay" version = "0.0.1" -# Stack that will be used by the builder +# Base images used to create the builder +[build] +image = "cnbs/sample-base-build:alpine" +[run] +[[run.images]] +image = "cnbs/sample-base-run:alpine" + +# Stack (deprecated) used to create the builder [stack] id = "io.buildpacks.samples.stacks.alpine" -run-image = "cnbs/sample-stack-run:alpine" -build-image = "cnbs/sample-stack-build:alpine" +build-image = "cnbs/sample-base-build:alpine" +run-image = "cnbs/sample-base-run:alpine" diff --git a/builders/dotnet-framework-2022/builder.toml b/builders/dotnet-framework-2022/builder.toml index f7b77dc1..46c6d0a1 100644 --- a/builders/dotnet-framework-2022/builder.toml +++ b/builders/dotnet-framework-2022/builder.toml @@ -10,8 +10,15 @@ uri = "../../buildpacks/dotnet-framework" id = "samples/dotnet-framework" version = "0.0.1" -# Stack that will be used by the builder +# Base images used to create the builder +[build] +image = "cnbs/sample-base-build:dotnet-framework-2022" +[run] +[[run.images]] +image = "cnbs/sample-base-run:dotnet-framework-2022" + +# Stack (deprecated) used to create the builder [stack] id = "io.buildpacks.samples.stacks.dotnet-framework-2022" -run-image = "cnbs/sample-stack-run:dotnet-framework-2022" -build-image = "cnbs/sample-stack-build:dotnet-framework-2022" \ No newline at end of file +build-image = "cnbs/sample-base-build:dotnet-framework-2022" +run-image = "cnbs/sample-base-run:dotnet-framework-2022" diff --git a/builders/jammy/builder.toml b/builders/jammy/builder.toml index 40a642b7..410ac467 100644 --- a/builders/jammy/builder.toml +++ b/builders/jammy/builder.toml @@ -38,8 +38,15 @@ version = "0.0.1" id = "samples/hello-universe" version = "0.0.1" -# Stack that will be used by the builder +# Base images used to create the builder +[build] +image = "cnbs/sample-base-build:jammy" +[run] +[[run.images]] +image = "cnbs/sample-base-run:jammy" + +# Stack (deprecated) used to create the builder [stack] id = "io.buildpacks.samples.stacks.jammy" -run-image = "cnbs/sample-stack-run:jammy" -build-image = "cnbs/sample-stack-build:jammy" +build-image = "cnbs/sample-base-build:jammy" +run-image = "cnbs/sample-base-run:jammy" diff --git a/builders/nanoserver-2022/builder.toml b/builders/nanoserver-2022/builder.toml index 0d276145..320359df 100644 --- a/builders/nanoserver-2022/builder.toml +++ b/builders/nanoserver-2022/builder.toml @@ -8,8 +8,15 @@ uri = "docker://cnbs/sample-package:hello-universe-windows" id = "samples/hello-universe-windows" version = "0.0.1" -# Stack that will be used by the builder +# Base images used to create the builder +[build] +image = "cnbs/sample-base-build:nanoserver-2022" +[run] +[[run.images]] +image = "cnbs/sample-base-run:nanoserver-2022" + +# Stack (deprecated) used to create the builder [stack] id = "io.buildpacks.samples.stacks.nanoserver-2022" -run-image = "cnbs/sample-stack-run:nanoserver-2022" -build-image = "cnbs/sample-stack-build:nanoserver-2022" +build-image = "cnbs/sample-base-build:nanoserver-2022" +run-image = "cnbs/sample-base-run:nanoserver-2022" diff --git a/buildpacks/dotnet-framework/buildpack.toml b/buildpacks/dotnet-framework/buildpack.toml index 8a539c22..fe3dec21 100755 --- a/buildpacks/dotnet-framework/buildpack.toml +++ b/buildpacks/dotnet-framework/buildpack.toml @@ -1,12 +1,18 @@ +# Buildpack API version api = "0.9" +# Buildpack ID and metadata [buildpack] - id = "samples/dotnet-framework" - version = "0.0.1" - name = "Sample .NET Framework Buildpack" +id = "samples/dotnet-framework" +version = "0.0.1" +name = "Sample .NET Framework Buildpack" -[[stacks]] - id = "io.buildpacks.samples.stacks.dotnet-framework-2022" +# Targets the buildpack will work with +[[targets]] +os = "windows" +[[targets.distros]] +version = "10.0.20348.1906" +# Stacks (deprecated) the buildpack will work with [[stacks]] - id = "io.buildpacks.samples.stacks.dotnet-framework-2022" +id = "io.buildpacks.samples.stacks.dotnet-framework-2022" diff --git a/buildpacks/hello-extensions/buildpack.toml b/buildpacks/hello-extensions/buildpack.toml index ded4deb3..c108f273 100644 --- a/buildpacks/hello-extensions/buildpack.toml +++ b/buildpacks/hello-extensions/buildpack.toml @@ -9,6 +9,10 @@ name = "Hello Extensions Buildpack" homepage = "https://github.com/buildpacks/samples/tree/main/buildpacks/hello-extensions" description = "A simple buildpack that requires curl." -# Stacks that the buildpack will work with +# Targets the buildpack will work with +[[targets]] +os = "linux" + +# Stacks (deprecated) the buildpack will work with [[stacks]] id = "*" diff --git a/buildpacks/hello-moon-windows/buildpack.toml b/buildpacks/hello-moon-windows/buildpack.toml index 216beeb2..fd89cf7d 100644 --- a/buildpacks/hello-moon-windows/buildpack.toml +++ b/buildpacks/hello-moon-windows/buildpack.toml @@ -8,9 +8,13 @@ version = "0.0.1" name = "Hello Moon Buildpack" homepage = "https://github.com/buildpacks/samples/tree/main/buildpacks/hello-moon-windows" -# Stacks that the buildpack will work with +# Targets the buildpack will work with +[[targets]] +os = "windows" + +# Stacks (deprecated) the buildpack will work with [[stacks]] id = "io.buildpacks.samples.stacks.nanoserver-2022" [[stacks]] - id = "io.buildpacks.samples.stacks.dotnet-framework-2022" +id = "io.buildpacks.samples.stacks.dotnet-framework-2022" diff --git a/buildpacks/hello-moon/buildpack.toml b/buildpacks/hello-moon/buildpack.toml index 8e38607a..c3c304e0 100644 --- a/buildpacks/hello-moon/buildpack.toml +++ b/buildpacks/hello-moon/buildpack.toml @@ -7,16 +7,12 @@ id = "samples/hello-moon" version = "0.0.1" name = "Hello Moon Buildpack" homepage = "https://github.com/buildpacks/samples/tree/main/buildpacks/hello-moon" +sbom-formats = ["application/vnd.cyclonedx+json"] -# Stacks that the buildpack will work with -[[stacks]] -id = "io.buildpacks.samples.stacks.jammy" - -[[stacks]] -id = "io.buildpacks.samples.stacks.alpine" - -[[stacks]] -id = "io.buildpacks.stacks.jammy" +# Targets the buildpack will work with +[[targets]] +os = "linux" +# Stacks (deprecated) the buildpack will work with [[stacks]] -id = "*" \ No newline at end of file +id = "*" diff --git a/buildpacks/hello-processes/buildpack.toml b/buildpacks/hello-processes/buildpack.toml index d4670508..fc79660c 100644 --- a/buildpacks/hello-processes/buildpack.toml +++ b/buildpacks/hello-processes/buildpack.toml @@ -8,15 +8,10 @@ version = "0.0.1" name = "Hello Processes Buildpack" homepage = "https://github.com/buildpacks/samples/tree/main/buildpacks/hello-process" -# Stacks that the buildpack will work with -[[stacks]] -id = "io.buildpacks.samples.stacks.jammy" - -[[stacks]] -id = "io.buildpacks.samples.stacks.alpine" - -[[stacks]] -id = "io.buildpacks.stacks.jammy" +# Targets the buildpack will work with +[[targets]] +os = "linux" +# Stacks (deprecated) the buildpack will work with [[stacks]] -id = "*" \ No newline at end of file +id = "*" diff --git a/buildpacks/hello-world-windows/buildpack.toml b/buildpacks/hello-world-windows/buildpack.toml index 33337eab..76999dbb 100644 --- a/buildpacks/hello-world-windows/buildpack.toml +++ b/buildpacks/hello-world-windows/buildpack.toml @@ -8,8 +8,15 @@ version = "0.0.1" name = "Hello World Buildpack" homepage = "https://github.com/buildpacks/samples/tree/main/buildpacks/hello-world-windows" +# Targets the buildpack will work with +[[targets]] +os = "windows" +[[targets.distros]] +version = "10.0.20348.1906" + +# Stacks (deprecated) the buildpack will work with [[stacks]] id = "io.buildpacks.samples.stacks.nanoserver-2022" [[stacks]] - id = "io.buildpacks.samples.stacks.dotnet-framework-2022" +id = "io.buildpacks.samples.stacks.dotnet-framework-2022" diff --git a/buildpacks/hello-world/buildpack.toml b/buildpacks/hello-world/buildpack.toml index 0c7c40c5..e1bd9829 100644 --- a/buildpacks/hello-world/buildpack.toml +++ b/buildpacks/hello-world/buildpack.toml @@ -8,15 +8,10 @@ version = "0.0.1" name = "Hello World Buildpack" homepage = "https://github.com/buildpacks/samples/tree/main/buildpacks/hello-world" -# Stacks that the buildpack will work with -[[stacks]] -id = "io.buildpacks.samples.stacks.jammy" - -[[stacks]] -id = "io.buildpacks.samples.stacks.alpine" - -[[stacks]] -id = "io.buildpacks.stacks.jammy" +# Targets the buildpack will work with +[[targets]] +os = "linux" +# Stacks (deprecated) the buildpack will work with [[stacks]] -id = "*" \ No newline at end of file +id = "*" diff --git a/buildpacks/java-maven/buildpack.toml b/buildpacks/java-maven/buildpack.toml index bb1caf62..b0d8b40f 100644 --- a/buildpacks/java-maven/buildpack.toml +++ b/buildpacks/java-maven/buildpack.toml @@ -8,17 +8,10 @@ version = "0.0.1" name = "Sample Java Maven Buildpack" homepage = "https://github.com/buildpacks/samples/tree/main/buildpacks/java-maven" +# Targets the buildpack will work with +[[targets]] +os = "linux" -# Stacks that the buildpack will work with -[[stacks]] -id = "io.buildpacks.samples.stacks.jammy" - -[[stacks]] -id = "io.buildpacks.samples.stacks.alpine" - +# Stacks (deprecated) the buildpack will work with [[stacks]] id = "*" - -[[stacks]] -id = "io.buildpacks.stacks.jammy" -mixins = ["build:set=shell-utils"] diff --git a/buildpacks/kotlin-gradle/buildpack.toml b/buildpacks/kotlin-gradle/buildpack.toml index 216fa1b8..d3ce6a79 100644 --- a/buildpacks/kotlin-gradle/buildpack.toml +++ b/buildpacks/kotlin-gradle/buildpack.toml @@ -8,16 +8,10 @@ version = "0.0.1" name = "Sample Kotlin Gradle Buildpack" homepage = "https://github.com/buildpacks/samples/tree/main/buildpacks/kotlin-gradle" -# Stacks that the buildpack will work with -[[stacks]] -id = "io.buildpacks.samples.stacks.jammy" - -[[stacks]] -id = "io.buildpacks.samples.stacks.alpine" +# Targets the buildpack will work with +[[targets]] +os = "linux" +# Stacks (deprecated) the buildpack will work with [[stacks]] id = "*" - -[[stacks]] -id = "io.buildpacks.stacks.jammy" -mixins = ["build:set=shell-utils"] diff --git a/buildpacks/ruby-bundler/buildpack.toml b/buildpacks/ruby-bundler/buildpack.toml index aa018435..56d32afa 100644 --- a/buildpacks/ruby-bundler/buildpack.toml +++ b/buildpacks/ruby-bundler/buildpack.toml @@ -8,13 +8,10 @@ version = "0.0.1" name = "Sample Ruby Buildpack" homepage = "https://github.com/buildpacks/samples/tree/main/buildpacks/ruby-bundler" -# Stacks that the buildpack will work with -[[stacks]] -id = "io.buildpacks.samples.stacks.jammy" +# Targets the buildpack will work with +[[targets]] +os = "linux" +# Stacks (deprecated) the buildpack will work with [[stacks]] id = "*" - -[[stacks]] -id = "io.buildpacks.stacks.jammy" -mixins = ["build:set=shell-utils"] diff --git a/stacks/alpine/base/Dockerfile b/stacks/alpine/base/Dockerfile deleted file mode 100755 index ad58d936..00000000 --- a/stacks/alpine/base/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM --platform=linux/amd64 alpine:3 - -ARG cnb_uid=1000 -ARG cnb_gid=1001 - -# Install packages that we want to make available at both build and run time -RUN apk add --update --no-cache bash ca-certificates - -# Create user and group -RUN addgroup -g ${cnb_gid} cnb && \ - adduser -u ${cnb_uid} -G cnb -s /bin/bash -D cnb - -# Set required CNB information -ENV CNB_USER_ID=${cnb_uid} -ENV CNB_GROUP_ID=${cnb_gid} \ No newline at end of file diff --git a/stacks/alpine/build/Dockerfile b/stacks/alpine/build/Dockerfile deleted file mode 100755 index 38f4eeb8..00000000 --- a/stacks/alpine/build/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -ARG base_image -FROM ${base_image} - -# Install packages that we want to make available at build time -RUN apk add --update ca-certificates git jq wget && \ - rm -rf /var/cache/apk/* - -COPY ./bin/yj-linux /usr/local/bin/yj - -# Set required CNB information -ARG stack_id -ENV CNB_STACK_ID=${stack_id} -LABEL io.buildpacks.stack.id=${stack_id} - -# Set user and group (as declared in base image) -USER ${CNB_USER_ID}:${CNB_GROUP_ID} \ No newline at end of file diff --git a/stacks/alpine/run/Dockerfile b/stacks/alpine/run/Dockerfile deleted file mode 100755 index e3ff6ca8..00000000 --- a/stacks/alpine/run/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -ARG base_image -FROM ${base_image} - -# Set required CNB information -ARG stack_id -LABEL io.buildpacks.stack.id="${stack_id}" - -# Set user and group (as declared in base image) -USER ${CNB_USER_ID}:${CNB_GROUP_ID} \ No newline at end of file diff --git a/stacks/alpine/run/curl.Dockerfile b/stacks/alpine/run/curl.Dockerfile deleted file mode 100644 index 82dd0539..00000000 --- a/stacks/alpine/run/curl.Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM curlimages/curl - -RUN curl --version - -ARG cnb_uid=1000 -ARG cnb_gid=1001 - -# Create user and group -USER root -RUN addgroup -g ${cnb_gid} cnb && \ - adduser -u ${cnb_uid} -G cnb -s /bin/bash -D cnb - -# Set user and group (as declared in base image) -USER ${CNB_USER_ID}:${CNB_GROUP_ID} - -# Set required CNB information -ENV CNB_USER_ID=${cnb_uid} -ENV CNB_GROUP_ID=${cnb_gid} - -# Set required CNB information -LABEL io.buildpacks.stack.id=io.buildpacks.samples.stacks.alpine - diff --git a/stacks/build-stack.sh b/stacks/build-stack.sh deleted file mode 100755 index d316e487..00000000 --- a/stacks/build-stack.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash -set -e - -ID_PREFIX="io.buildpacks.samples.stacks" - -DEFAULT_PREFIX=cnbs/sample-stack -DEFAULT_PLATFORM=amd64 - -REPO_PREFIX=${DEFAULT_PREFIX} -PLATFORM=${DEFAULT_PLATFORM} - -usage() { - echo "Usage: " - echo " $0 [-f ] [-p ] " - echo " -f prefix to use for images (default: ${DEFAULT_PREFIX})" - echo " -p prefix to use for images (default: ${DEFAULT_PLATFORM})" - echo " directory of stack to build" - exit 1; -} - -while getopts "v:p:" o; do - case "${o}" in - f) - REPO_PREFIX=${OPTARG} - ;; - p) - PLATFORM=${OPTARG} - ;; - \?) - echo "Invalid option: -$OPTARG" 1>&2 - usage - ;; - :) - usage - ;; - esac -done - -STACK_DIR=${@:$OPTIND:1} - -if [[ -z ${REPO_PREFIX} ]]; then - echo "Prefix cannot be empty" - echo - usage - exit 1 -fi - -if [[ -z ${STACK_DIR} ]]; then - echo "Must specify stack directory" - echo - usage - exit 1 -fi - -DIR=$(cd $(dirname $0) && pwd) -IMAGE_DIR=$(realpath "${STACK_DIR}") -TAG=$(basename "${IMAGE_DIR}") -STACK_ID="${ID_PREFIX}.$(basename "${IMAGE_DIR}")" -BASE_IMAGE=${REPO_PREFIX}-base:${TAG} -RUN_IMAGE=${REPO_PREFIX}-run:${TAG} -BUILD_IMAGE=${REPO_PREFIX}-build:${TAG} - -if [[ -d "${IMAGE_DIR}/base" ]]; then - docker build --platform=${PLATFORM} -t "${BASE_IMAGE}" "${IMAGE_DIR}/base" -fi - -echo "BUILDING ${BUILD_IMAGE}..." -docker build --platform=${PLATFORM} --build-arg "base_image=${BASE_IMAGE}" --build-arg "stack_id=${STACK_ID}" -t "${BUILD_IMAGE}" "${IMAGE_DIR}/build" - -echo "BUILDING ${RUN_IMAGE}..." -docker build --platform=${PLATFORM} --build-arg "base_image=${BASE_IMAGE}" --build-arg "stack_id=${STACK_ID}" -t "${RUN_IMAGE}" "${IMAGE_DIR}/run" - -echo -echo "STACK BUILT!" -echo -echo "Stack ID: ${STACK_ID}" -echo "Images:" -for IMAGE in "${BASE_IMAGE}" "${BUILD_IMAGE}" "${RUN_IMAGE}"; do - echo " ${IMAGE}" -done \ No newline at end of file diff --git a/stacks/dotnet-framework-2022/build/Dockerfile b/stacks/dotnet-framework-2022/build/Dockerfile deleted file mode 100644 index 179ee0a8..00000000 --- a/stacks/dotnet-framework-2022/build/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022 - -ARG stack_id - -# non-zero sets all user-owned directories to BUILTIN\Users -ARG cnb_uid=1 -ARG cnb_gid=1 - -ENV CNB_USER_ID=${cnb_uid} -ENV CNB_GROUP_ID=${cnb_gid} - -LABEL io.buildpacks.stack.id=${stack_id} -ENV CNB_STACK_ID=${stack_id} - -USER ContainerAdministrator diff --git a/stacks/jammy/base/Dockerfile b/stacks/jammy/base/Dockerfile deleted file mode 100755 index 6606257c..00000000 --- a/stacks/jammy/base/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM --platform=linux/amd64 ubuntu:jammy - -ARG cnb_uid=1000 -ARG cnb_gid=1000 - -# Install packages that we want to make available at both build and run time -RUN apt update && \ - apt install -y xz-utils ca-certificates libyaml-0-2 && \ - rm -rf /var/lib/apt/lists/* - -# Create user and group -RUN groupadd cnb --gid ${cnb_gid} && \ - useradd --uid ${cnb_uid} --gid ${cnb_gid} -m -s /bin/bash cnb - -# Set required CNB information -ENV CNB_USER_ID=${cnb_uid} -ENV CNB_GROUP_ID=${cnb_gid} \ No newline at end of file diff --git a/stacks/jammy/build/Dockerfile b/stacks/jammy/build/Dockerfile deleted file mode 100755 index 221bfbf0..00000000 --- a/stacks/jammy/build/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -ARG base_image -FROM ${base_image} - -# Install packages that we want to make available at build time -RUN apt update && \ - apt install -y git wget jq && \ - rm -rf /var/lib/apt/lists/* - -COPY ./bin/yj-linux /usr/local/bin/yj - -# Set required CNB information -ARG stack_id -ENV CNB_STACK_ID=${stack_id} -LABEL io.buildpacks.stack.id=${stack_id} - -# Set user and group (as declared in base image) -USER ${CNB_USER_ID}:${CNB_GROUP_ID} \ No newline at end of file diff --git a/stacks/jammy/run/Dockerfile b/stacks/jammy/run/Dockerfile deleted file mode 100755 index e3ff6ca8..00000000 --- a/stacks/jammy/run/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -ARG base_image -FROM ${base_image} - -# Set required CNB information -ARG stack_id -LABEL io.buildpacks.stack.id="${stack_id}" - -# Set user and group (as declared in base image) -USER ${CNB_USER_ID}:${CNB_GROUP_ID} \ No newline at end of file diff --git a/stacks/nanoserver-2022/base/Dockerfile b/stacks/nanoserver-2022/base/Dockerfile deleted file mode 100755 index 02eef5c1..00000000 --- a/stacks/nanoserver-2022/base/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 - -# non-zero sets all user-owned directories to BUILTIN\Users -ARG cnb_uid=1 -ARG cnb_gid=1 - -ENV CNB_USER_ID=${cnb_uid} -ENV CNB_GROUP_ID=${cnb_gid} - -# launcher requires a non-empty PATH to workaround https://github.com/buildpacks/pack/issues/800 -ENV PATH c:\\Windows\\system32;C:\\Windows - -USER ContainerUser diff --git a/stacks/nanoserver-2022/build/Dockerfile b/stacks/nanoserver-2022/build/Dockerfile deleted file mode 100755 index c0e096d3..00000000 --- a/stacks/nanoserver-2022/build/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -ARG base_image - -FROM ${base_image} - -ARG stack_id - -LABEL io.buildpacks.stack.id=${stack_id} -ENV CNB_STACK_ID=${stack_id} diff --git a/stacks/nanoserver-2022/run/Dockerfile b/stacks/nanoserver-2022/run/Dockerfile deleted file mode 100755 index 68e19733..00000000 --- a/stacks/nanoserver-2022/run/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -ARG base_image - -FROM ${base_image} - -ARG stack_id - -LABEL io.buildpacks.stack.id=${stack_id}