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 Jun 19, 2024
1 parent 3e53a00 commit 959e2a5
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 88 deletions.
82 changes: 78 additions & 4 deletions images/nginx/config/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,87 @@ terraform {

variable "extra_packages" {
description = "The additional packages to install (e.g. nginx-mainline)."
type = list(string)
default = []
}

data "apko_config" "this" {
config_contents = file("${path.module}/template.apko.yaml")
extra_packages = var.extra_packages
variable "entrypoint" {
description = "The entrypoint for the image."
type = string
default = "/usr/sbin/nginx"
}

variable "command" {
description = "The command to be run as part of the entrypoint."
type = string
default = "-c /etc/nginx/nginx.conf -e /dev/stderr -g \"daemon off;\""
}

variable "extra_paths" {
description = "Extra paths to mount in the image."
default = []
}

variable "uid" {
description = "UID of the user the image should run as."
type = number
default = 65532
}

variable "gid" {
description = "UID of the user the image should run as."
type = number
default = 65532
}

module "accts" {
source = "../../../tflib/accts"
name = "nginx"
uid = var.uid
gid = var.gid
}

output "config" {
value = jsonencode(data.apko_config.this.config)
value = jsonencode({
contents = { packages = var.extra_packages }

accounts = module.accts.block

paths = concat([
{
path = "/var/lib/nginx"
type = "directory"
uid = var.uid
gid = var.gid
permissions = 493 // 0755
recursive = true
},
{
path = "/var/lib/nginx/tmp"
uid = var.uid
gid = var.gid
type = "directory"
# Wide permissions required for running with tmpfs. Seems to be related to Docker bug https://github.com/moby/moby/issues/40881
permissions : 511 // 0777
recursive = true
},
{
path = "/var/run"
uid = var.uid
gid = var.gid
type = "directory"
# Wide permissions required for running with tmpfs. Seems to be related to Docker bug https://github.com/moby/moby/issues/40881
permissions = 511 // 0777
recursive = false
},
], var.extra_paths)

entrypoint = {
command = var.entrypoint
}

cmd = var.command

stop-signal = "SIGQUIT"
})
}
45 changes: 0 additions & 45 deletions images/nginx/config/template.apko.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion images/nginx/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ variable "target_repository" {

module "latest-config" {
source = "./config"
extra_packages = ["nginx-mainline", "nginx-mainline-package-config", "docker-nginx"]
extra_packages = ["nginx-mainline", "nginx-mainline-package-config"]
}

module "latest" {
Expand Down
35 changes: 0 additions & 35 deletions images/nginx/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,38 +101,3 @@ EOT
},
]
}

resource "imagetest_feature" "check-template" {
name = "check template"
harness = imagetest_harness_docker.docker

steps = [
{
name = "Copy template file"
cmd = <<EOT
cp /tests/new.conf.template /data
EOT
},
{
name = "Check templated startup"
cmd = <<EOT
cleanup () {
docker logs $CONTAINER_NAME
docker rm -f $CONTAINER_NAME
docker network rm $NETWORK_NAME
}
trap cleanup EXIT
CONTAINER_NAME="nginx-template-$RANDOM_PET_SUFFIX"
NETWORK_NAME="nginx-template-$RANDOM_PET_SUFFIX"
NGINX_PORT=8888
docker network create $NETWORK_NAME
docker run -d --name $CONTAINER_NAME --network $NETWORK_NAME --env PORT=$NGINX_PORT -v $VOLUME_ID:/etc/nginx/templates/ $IMAGE_NAME
docker run --rm --network $NETWORK_NAME cgr.dev/chainguard/curl:latest http://$CONTAINER_NAME:$NGINX_PORT
EOT
},
]
}
3 changes: 0 additions & 3 deletions images/nginx/tests/new.conf.template

This file was deleted.

0 comments on commit 959e2a5

Please sign in to comment.