-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/github_actions/actions/upload-art…
…ifact-4
- Loading branch information
Showing
24 changed files
with
512 additions
and
13 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,18 @@ | ||
module "alpine" { source = "./config/alpine" } | ||
|
||
module "latest-alpine" { | ||
providers = { | ||
apko = apko.alpine | ||
} | ||
source = "../../tflib/publisher" | ||
|
||
target_repository = var.target_repository | ||
config = module.alpine.config | ||
# Override the module's default wolfi packages that conflict with alpine | ||
extra_packages = [] | ||
} | ||
|
||
module "test-latest-alpine" { | ||
source = "./tests" | ||
digest = module.latest-alpine.image_ref | ||
} |
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 @@ | ||
variable "extra_packages" { | ||
description = "Extra packages to install." | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
output "config" { | ||
value = jsonencode({ | ||
contents = { | ||
packages = concat([ | ||
"busybox", | ||
"ssl_client", # ssl_client allows the busybox wget applet to use https. | ||
], var.extra_packages) | ||
} | ||
accounts = { | ||
groups = [{ | ||
groupname = "nonroot" | ||
gid = 65532 | ||
}] | ||
users = [{ | ||
username = "nonroot" | ||
uid = 65532 | ||
gid = 65532 | ||
}] | ||
run-as = 65532 | ||
} | ||
}) | ||
} |
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,30 @@ | ||
terraform { | ||
required_providers { | ||
oci = { source = "chainguard-dev/oci" } | ||
apko = { | ||
source = "chainguard-dev/apko" | ||
configuration_aliases = [apko.alpine] | ||
} | ||
} | ||
} | ||
|
||
provider "apko" { | ||
alias = "alpine" | ||
|
||
extra_repositories = ["https://dl-cdn.alpinelinux.org/alpine/edge/main"] | ||
# These packages match chainguard-images/static | ||
extra_packages = ["alpine-baselayout-data", "alpine-release", "ca-certificates-bundle"] | ||
// Don't build for riscv64, 386, arm/v6 | ||
// Only build for: amd64, arm/v7, arm64, ppc64le, s390x | ||
default_archs = ["amd64", "arm/v7", "arm64", "ppc64le", "s390x"] | ||
} | ||
|
||
variable "target_repository" { | ||
description = "The docker repo into which the image and attestations should be published." | ||
} | ||
|
||
resource "oci_tag" "alpine" { | ||
depends_on = [module.test-latest-alpine] | ||
digest_ref = module.latest-alpine.image_ref | ||
tag = "alpine" | ||
} |
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,14 @@ | ||
terraform { | ||
required_providers { | ||
oci = { source = "chainguard-dev/oci" } | ||
} | ||
} | ||
|
||
variable "digest" { | ||
description = "The image digest to run tests over." | ||
} | ||
|
||
data "oci_exec_test" "runs" { | ||
digest = var.digest | ||
script = "${path.module}/runs.sh" | ||
} |
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,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit -o nounset -o errtrace -o pipefail -x | ||
|
||
docker run --rm $IMAGE_NAME ls >/dev/null | ||
|
||
# The image runs as nonroot by default. | ||
docker run --rm --entrypoint '' $IMAGE_NAME whoami | grep "^nonroot$" | ||
|
||
# The image contains many common utilities (some in /usr/bin and some in /bin) | ||
for cmd in awk basename cat chmod chown cp cut date dirname du echo egrep expr find grep head id ln ls mkdir mktemp mv printf pwd rm rmdir sed sh sort tail tar tee test touch tr uname uniq wc xargs; do | ||
docker run --rm $IMAGE_NAME which $cmd | grep "/bin/$cmd$" | ||
done | ||
|
||
# The image can be used as a base image. | ||
cat <<EOF | docker build -t version - | ||
FROM ${IMAGE_NAME} | ||
RUN busybox | ||
ENTRYPOINT ["busybox"] | ||
EOF | ||
docker run --rm version | grep "BusyBox .* multi-call binary." |
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,23 @@ | ||
module "alpine" { | ||
for_each = local.accounts | ||
source = "./config" | ||
root = each.key == "root" | ||
extra_repositories = ["https://dl-cdn.alpinelinux.org/alpine/edge/community"] | ||
} | ||
|
||
module "latest-alpine" { | ||
providers = { | ||
apko = apko.alpine | ||
} | ||
for_each = local.accounts | ||
source = "../../tflib/publisher" | ||
target_repository = var.target_repository | ||
config = module.alpine[each.key].config | ||
extra_packages = [] // Don't add wolfi-baselayout | ||
} | ||
|
||
module "test-latest-alpine" { | ||
for_each = local.accounts | ||
source = "./tests" | ||
digest = module.latest-alpine[each.key].image_ref | ||
} |
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,46 @@ | ||
variable "extra_packages" { | ||
description = "Extra packages to install." | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
variable "extra_repositories" { | ||
description = "Extra repositories to add." | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
variable "root" { | ||
description = "Whether to run as root." | ||
type = bool | ||
default = false | ||
} | ||
|
||
output "config" { | ||
value = jsonencode({ | ||
contents = { | ||
repositories = var.extra_repositories | ||
packages = concat([ | ||
"git", | ||
"git-lfs", | ||
"openssh-client", | ||
], var.extra_packages) | ||
} | ||
accounts = { | ||
groups = [{ | ||
groupname = "git" | ||
gid = 65532 | ||
}] | ||
users = [{ | ||
username = "git" | ||
uid = 65532 | ||
gid = 65532 | ||
}] | ||
run-as = var.root ? 0 : 65532 | ||
} | ||
entrypoint = { | ||
command = "/usr/bin/git" | ||
} | ||
work-dir = "/home/git" | ||
}) | ||
} |
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,40 @@ | ||
terraform { | ||
required_providers { | ||
oci = { source = "chainguard-dev/oci" } | ||
apko = { | ||
source = "chainguard-dev/apko" | ||
configuration_aliases = [apko.alpine] | ||
} | ||
} | ||
} | ||
|
||
provider "apko" { | ||
alias = "alpine" | ||
|
||
extra_repositories = ["https://dl-cdn.alpinelinux.org/alpine/edge/main"] | ||
# These packages match chainguard-images/static | ||
extra_packages = ["alpine-baselayout-data", "alpine-release", "ca-certificates-bundle"] | ||
// Don't build for riscv64, 386, arm/v6 | ||
// Only build for: amd64, arm/v7, arm64, ppc64le, s390x | ||
default_archs = ["amd64", "arm/v7", "arm64", "ppc64le", "s390x"] | ||
} | ||
|
||
locals { | ||
accounts = toset(["nonroot", "root"]) | ||
} | ||
|
||
variable "target_repository" { | ||
description = "The docker repo into which the image and attestations should be published." | ||
} | ||
|
||
resource "oci_tag" "alpine" { | ||
depends_on = [module.test-latest-alpine] | ||
digest_ref = module.latest-alpine["nonroot"].image_ref | ||
tag = "alpine" | ||
} | ||
|
||
resource "oci_tag" "alpine-root" { | ||
depends_on = [module.test-latest-alpine] | ||
digest_ref = module.latest-alpine["root"].image_ref | ||
tag = "alpine-root" | ||
} |
Oops, something went wrong.