Skip to content

Commit

Permalink
automated commit
Browse files Browse the repository at this point in the history
Signed-off-by: Public copy <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Dec 12, 2024
1 parent 93ef45f commit 3e2de14
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 0 deletions.
101 changes: 101 additions & 0 deletions images/wordpress/config/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
variable "base_packages" {
default = [
"curl",
"ca-certificates",
"imagemagick",
"php",
"php-fpm",
"php-ctype",
"php-curl",
"php-dom",
"php-fileinfo",
"php-iconv",
"php-mbstring",
"php-mysqlnd",
"php-openssl",
"php-bcmath",
"php-intl",
"php-sodium",
"php-simplexml",
"php-xml",
"php-igbinary",
"php-mysqli",
"php-zip",
"php-xmlwriter",
"php-xmlreader",
"php-imagick",
"php-opcache",
"wordpress"
]
description = "The additional packages to install (e.g. php-fpm)."
}

variable "php_version" {
default = "php"
description = "Major php version for all the deps"
}

variable "dev_packages" {
default = ["wolfi-base", "wordpress-oci-entrypoint"]
description = "The additional packages to install in the dev image."
}

variable "wp-paths" {
default = [{
path = "/var/www/html",
type = "directory",
uid = 65532,
gid = 65532,
permissions = 493,
}]
description = "File paths for the image"
}

module "accts" {
name = "php"
source = "../../../tflib/accts"
}

output "config" {
value = jsonencode({
contents = {
packages = [for p in var.base_packages : replace(p, "php", var.php_version)]
}
accounts = module.accts.block
entrypoint = { command = "php-fpm" }
work-dir = "/var/www/html"
paths = var.wp-paths
environment = {
PATH = "/usr/sbin:/sbin:/usr/bin:/bin"
}
})
}

output "config-dev" {
value = jsonencode({
contents = {
packages = concat([for p in var.base_packages : replace(p, "php", var.php_version)], var.dev_packages)
}
accounts = module.accts.block
entrypoint = { command = "/usr/local/bin/docker-entrypoint.sh php-fpm" }
work-dir = "/var/www/html"
paths = concat(var.wp-paths, [{
path = "/var/www/html/wp-content",
type = "directory",
uid = module.accts.block.run-as,
gid = module.accts.block.run-as,
permissions = 511,
}, {
path = "/usr/src/wordpress",
type = "directory",
uid = 65532,
gid = 65532,
permissions = 493,
}
])
environment = {
PATH = "/usr/sbin:/sbin:/usr/bin:/bin"
}
})
}

49 changes: 49 additions & 0 deletions images/wordpress/tests/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
terraform {
required_providers {
imagetest = { source = "chainguard-dev/imagetest" }
oci = { source = "chainguard-dev/oci" }
}
}

variable "digest" {
description = "The image digest to run tests over."
}

data "imagetest_inventory" "inventory" {
}

resource "random_id" "id" {
byte_length = 4
}

resource "imagetest_harness_docker" "docker" {
envs = {
IMAGE_NAME : var.digest
WP_CONTAINER_NAME : "wordpress-${random_id.id.hex}"
}
inventory = data.imagetest_inventory.inventory
name = "docker-wordpress"
}

resource "imagetest_feature" "wordpress-basic" {
harness = imagetest_harness_docker.docker
name = "docker-test-wordpress"
steps = [{
name = "Start up WordPress container"
cmd = <<EOT
docker run --detach --rm --name "$WP_CONTAINER_NAME" $IMAGE_NAME
EOT
}, {
name = "Check Logs"
cmd = <<EOT
docker logs "$WP_CONTAINER_NAME" 2>&1 | grep -q "ready to handle connections"
EOT
retry = { attempts = 15, delay = "30s" }
}, {
name = "stop container"
cmd = <<EOT
docker stop $WP_CONTAINER_NAME
EOT
}]
}

0 comments on commit 3e2de14

Please sign in to comment.