forked from getporter/porter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support additional docker build flags
This adds support for the following docker flags: --build-arg: Pass build arguments that can be used in the template dockerfile --ssh: Provide a ssh configuration to the container while building --secret: Provide a secret to the container while building --no-cache: Build the image and do not use cached layers. It also fixes how we call the docker buildx plugin so that user configuration, such as a proxy, is used. After upgrading to a new version of buildx, I was also able to pick up a fix for pretty printing the progress to stderr, while capturing the plaintext output to the logs. Closes getporter#1769 Closes getporter#1941 Signed-off-by: Carolyn Van Slyck <[email protected]>
- Loading branch information
Showing
27 changed files
with
434 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file | ||
# Put files here that you don't want copied into your bundle's invocation image | ||
.gitignore | ||
Dockerfile.tmpl | ||
secrets/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.cnab/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Bundle with Private Assets | ||
|
||
Sometimes you need to include assets from secured locations, such as a private repository in your bundle. | ||
You can use the \--secret flag to pass secrets into the bundle when it is built. | ||
|
||
## Try it out | ||
1. Edit secrets/token and replace the contents with a [GitHub Personal Access Token](https://github.com/settings/tokens). | ||
The permissions do not matter for this sample bundle. | ||
There should not be a newline at the end of the file. | ||
|
||
1. Build the bundle and pass the secret into the bundle with \--secret | ||
``` | ||
porter build --secret id=token,src=secrets/token | ||
``` | ||
1. Install the bundle to see the private assets embedded in the bundle | ||
``` | ||
$ porter install example-private-assets --reference ghcr.io/getporter/examples/private-assets:v0.1.0 | ||
__________________________ | ||
< yarr, I'm a secret whale > | ||
-------------------------- | ||
\ | ||
\ | ||
\ | ||
## . | ||
## ## ## == | ||
## ## ## ## === | ||
/""""""""""""""""___/ === | ||
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~ | ||
\______ o __/ | ||
\ \ __/ | ||
\____\______/ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
if [[ ! -f "/run/secrets/token" ]]; then | ||
echo "You forgot to use --secret id=token,src=secrets/token" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
install() { | ||
echo Hello World | ||
} | ||
|
||
upgrade() { | ||
echo World 2.0 | ||
} | ||
|
||
uninstall() { | ||
echo Goodbye World | ||
} | ||
|
||
# Call the requested function and pass the arguments as-is | ||
"$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
schemaVersion: 1.0.0-alpha.1 | ||
|
||
name: private-assets | ||
version: 0.1.0 | ||
description: "Example bundle that contains private assets and prints it when run" | ||
registry: ghcr.io/getporter/examples/ | ||
dockerfile: template.Dockerfile | ||
|
||
mixins: | ||
- exec | ||
|
||
install: | ||
- exec: | ||
command: cat | ||
arguments: | ||
- /secret | ||
|
||
upgrade: | ||
- exec: | ||
command: cat | ||
arguments: | ||
- /secret | ||
|
||
uninstall: | ||
- exec: | ||
command: cat | ||
arguments: | ||
- /secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
REPLACE_WITH_YOUR_GITHUB_TOKEN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# syntax=docker/dockerfile-upstream:1.4.0-rc2 | ||
FROM debian:stretch-slim | ||
|
||
# PORTER_INIT | ||
|
||
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache | ||
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ | ||
apt-get update && apt-get install -y ca-certificates curl | ||
|
||
# PORTER_MIXINS | ||
|
||
# Use the BUNDLE_DIR build argument to copy files into the bundle's working directory | ||
COPY --link . ${BUNDLE_DIR} | ||
|
||
# Check the secret was passed to the build command | ||
RUN --mount=type=secret,id=token /cnab/app/check-secrets.sh | ||
|
||
# Use the injected secrets to build private assets into the bundle | ||
RUN --mount=type=secret,id=token curl -O https://$(cat /run/secrets/token)@gist.githubusercontent.com/carolynvs/860a0d26de3af1468d290a075a91aac9/raw/c53223acd284830e8f541cf35eba94dde0ddf75d/secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.