Skip to content

Commit

Permalink
Adds sample buildpackages for Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Micah Young <[email protected]>
  • Loading branch information
Micah Young committed Oct 12, 2020
1 parent cb8ff3e commit c2e07c4
Show file tree
Hide file tree
Showing 14 changed files with 153 additions and 18 deletions.
24 changes: 20 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ clean-linux:
docker rmi sample-ruby-bundler-app:bionic || true

@echo "> Removing packages..."
docker rmi cnbs/sample-package:hello-world || true
docker rmi cnbs/sample-package:hello-universe || true

@echo "> Removing '.tmp'"
Expand All @@ -143,7 +144,7 @@ clean-linux:
## Windows
####################

build-windows: build-windows-stacks build-windows-builders build-windows-buildpacks # build-windows-packages: not yet supported
build-windows: build-windows-stacks build-windows-packages build-windows-builders build-windows-buildpacks

build-nanoserver-1809: build-stack-nanoserver-1809 build-builder-nanoserver-1809 build-buildpacks-nanoserver-1809

Expand All @@ -159,32 +160,42 @@ build-stack-dotnet-framework-1809:

build-windows-builders: build-builder-nanoserver-1809 build-builder-dotnet-framework-1809

build-builder-nanoserver-1809: build-sample-root # build-windows-packages: not yet supported
build-builder-nanoserver-1809: build-sample-root build-windows-packages
@echo "> Building 'nanoserver-1809' builder..."
$(PACK_CMD) create-builder cnbs/sample-builder:nanoserver-1809 --config $(SAMPLES_ROOT)/builders/nanoserver-1809/builder.toml $(PACK_FLAGS)

build-builder-dotnet-framework-1809: build-sample-root # build-windows-packages: not yet supported
build-builder-dotnet-framework-1809: build-sample-root build-windows-packages
@echo "> Building 'dotnet-framework-1809' builder..."
$(PACK_CMD) create-builder cnbs/sample-builder:dotnet-framework-1809 --config $(SAMPLES_ROOT)/builders/dotnet-framework-1809/builder.toml $(PACK_FLAGS)

build-windows-buildpacks: build-buildpacks-nanoserver-1809 build-buildpacks-dotnet-framework-1809

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 --builder cnbs/sample-builder:nanoserver-1809 --buildpack $(SAMPLES_ROOT)/buildpacks/hello-world-windows --buildpack $(SAMPLES_ROOT)/buildpacks/hello-moon-windows $(PACK_FLAGS) $(PACK_BUILD_FLAGS)

@echo "> Creating 'hello-world-windows' app using 'nanoserver-1809' builder..."
$(PACK_CMD) build sample-hello-world-windows-app:nanoserver-1809 --builder cnbs/sample-builder:nanoserver-1809 --buildpack $(SAMPLES_ROOT)/buildpacks/hello-world-windows $(PACK_FLAGS) $(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 --builder cnbs/sample-builder:dotnet-framework-1809 --buildpack $(SAMPLES_ROOT)/buildpacks/dotnet-framework --path apps/aspnet $(PACK_FLAGS) $(PACK_BUILD_FLAGS)

build-windows-packages: build-sample-root
@echo "> Creating 'hello-world-windows' buildpack package"
$(PACK_CMD) package-buildpack cnbs/sample-package:hello-world-windows --config $(SAMPLES_ROOT)/packages/hello-world-windows/package.toml $(PACK_FLAGS)

@echo "> Creating 'hello-universe-windows' buildpack package"
$(PACK_CMD) package-buildpack cnbs/sample-package:hello-universe-windows --config $(SAMPLES_ROOT)/packages/hello-universe-windows/package.toml $(PACK_FLAGS)

build-windows-apps: build-sample-root
@echo "> Creating 'batch-script' app using 'nanoserver-1809' builder..."
$(PACK_CMD) build sample-batch-script-app:nanoserver-1809 --builder cnbs/sample-builder:nanoserver-1809 --path apps/batch-script $(PACK_FLAGS) $(PACK_BUILD_FLAGS)

@echo "> Creating 'aspnet' app using 'dotnet-framework-1809' builder..."
$(PACK_CMD) build sample-aspnet-app:dotnet-framework-1809 --builder cnbs/sample-builder:dotnet-framework-1809 --path apps/aspnet $(PACK_FLAGS) $(PACK_BUILD_FLAGS)

deploy-windows: deploy-windows-stacks deploy-windows-builders # deploy-windows-packages: not yet supported
deploy-windows: deploy-windows-stacks deploy-windows-builders deploy-windows-packages

deploy-windows-stacks:
@echo "> Deploying 'nanoserver-1809' stack..."
Expand Down Expand Up @@ -218,12 +229,17 @@ clean-windows:
docker rmi cnbs/sample-builder:dotnet-framework-1809 || 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 packages..."
docker rmi cnbs/sample-package:hello-world-windows || true
docker rmi cnbs/sample-package:hello-universe-windows || true

@echo "> Removing '.tmp'"
rm -rf .tmp

Expand Down
6 changes: 2 additions & 4 deletions builders/nanoserver-1809/builder.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Buildpacks to include in builder
[[buildpacks]]
id = "samples/hello-world-windows"
version = "0.0.1"
uri = "../../buildpacks/hello-world-windows"
image = "cnbs/sample-package:hello-universe-windows"

# Order used for detection
[[order]]
[[order.group]]
id = "samples/hello-world-windows"
id = "samples/hello-universe-windows"
version = "0.0.1"

# Stack that will be used by the builder
Expand Down
15 changes: 15 additions & 0 deletions buildpacks/hello-moon-windows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Sample: Hello World Buildpack

A no-op buildpack whose intent is to show how buildpack dependencies work. This buildpack depends on [hello-world](../hello-world).

### Usage

```bash
pack build sample-hello-moon-app --builder cnbs/sample-builder:alpine --buildpack ../hello-world/ --buildpack .
```

OR

```bash
pack build sample-hello-moon-app --builder cnbs/sample-builder:bionic --buildpack ../hello-world/ --buildpack .
```
27 changes: 27 additions & 0 deletions buildpacks/hello-moon-windows/bin/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@echo off

echo --- Hello Moon buildpack

set env_dir=%2\env
set layers_dir=%1
set plan_path=%3

echo env_dir: %env_dir%
echo env_vars:
for /f "tokens=*" %%f in ('dir /s /q /b %env_dir%') do (
for /f %%v in ('type %%f') do (
set %%~nf=%%v
)
)
for /f "tokens=*" %%o in ('set') do (
echo %%o
)

echo layers_dir: %layers_dir%
echo plan_path: %plan_path%
echo plan contents:
for /f "tokens=*" %%o in ('type %plan_path%') do (
echo %%o
)

echo --- Done
16 changes: 16 additions & 0 deletions buildpacks/hello-moon-windows/bin/detect.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@echo off

:: 1. GET ARGS
set plan_path=%2

:: 2. DECLARE DEPENDENCIES (OPTIONAL)
(
echo [[requires]]
echo name = "some-world"
echo version = "0.1"

echo [requires.metadata]
echo world = "Earth-616"
) >> %plan_path%

exit /b 0
16 changes: 16 additions & 0 deletions buildpacks/hello-moon-windows/buildpack.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Buildpack API version
api = "0.2"

# Buildpack ID and metadata
[buildpack]
id = "samples/hello-moon-windows"
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
[[stacks]]
id = "io.buildpacks.samples.stacks.nanoserver-1809"

[[stacks]]
id = "io.buildpacks.samples.stacks.dotnet-framework-1809"
10 changes: 2 additions & 8 deletions buildpacks/hello-moon/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
# Sample: Hello World Buildpack

A no-op buildpack whose intent is to show how buildpack dependencies work. This buildpack depends on [hello-world](../hello-world).
A no-op buildpack whose intent is to show how buildpack dependencies work. This buildpack depends on [hello-world-windows](../hello-world-windows).

### Usage

```bash
pack build sample-hello-moon-app --builder cnbs/sample-builder:alpine --buildpack ../hello-world/ --buildpack .
pack build sample-hello-moon-windows-app --builder cnbs/sample-builder:nanoserver-1809 --buildpack ../hello-world-windows/ --buildpack .
```

OR

```bash
pack build sample-hello-moon-app --builder cnbs/sample-builder:bionic --buildpack ../hello-world/ --buildpack .
```
13 changes: 13 additions & 0 deletions buildpacks/hello-universe-windows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Sample: Hello Universe Buildpack

A no-op meta-buildpack whose intent is to show how meta-buildpacks are constructed.

### Usage

```bash
pack build sample-hello-universe-windows-app \
--builder cnbs/sample-builder:nanoserver-1809 \
--buildpack . \
--buildpack ../hello-world-windows/ \
--buildpack ../hello-moon-windows/
```
19 changes: 19 additions & 0 deletions buildpacks/hello-universe-windows/buildpack.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Buildpack API version
api = "0.2"

# Buildpack ID and metadata
[buildpack]
id = "samples/hello-universe-windows"
version = "0.0.1"
name = "Hello Universe Buildpack"
homepage = "https://github.com/buildpacks/samples/tree/main/buildpacks/hello-universe-windows"

# Order used for detection
[[order]]
[[order.group]]
id = "samples/hello-world-windows"
version = "0.0.1"

[[order.group]]
id = "samples/hello-moon-windows"
version = "0.0.1"
2 changes: 1 addition & 1 deletion buildpacks/hello-world-windows/buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ 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-1809"
9 changes: 9 additions & 0 deletions packages/hello-universe-windows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Sample: Hello Universe Buildpack (Packaged)

A no-op buildpack whose intent is to show how meta-buildpacks can be packaged.

### Usage

```bash
pack create-package cnbs/sample-package:hello-universe-windows --config package.toml
```
10 changes: 10 additions & 0 deletions packages/hello-universe-windows/package.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[buildpack]
uri = "../../buildpacks/hello-universe-windows"

[[dependencies]]
uri = "../../buildpacks/hello-moon-windows"

[[dependencies]]
uri = "../../buildpacks/hello-world-windows"
# Alternatively, to use an image while packaging, you can use:
# image = "cnbs/sample-package:hello-world-windows"
2 changes: 1 addition & 1 deletion packages/hello-universe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ A no-op buildpack whose intent is to show how meta-buildpacks can be packaged.

```bash
pack create-package cnbs/sample-package:hello-universe --config package.toml
```
```
2 changes: 2 additions & 0 deletions packages/hello-world-windows/package.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[buildpack]
uri = "../../buildpacks/hello-world-windows"

0 comments on commit c2e07c4

Please sign in to comment.