Skip to content

Add injection of WP_MEMORY_LIMIT into entrypoint #56

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ For any issues relating to this module, [raise an issue against this repo.](http
| <a name="input_wordpress_admin_email"></a> [wordpress\_admin\_email](#input\_wordpress\_admin\_email) | The email address of the default wordpress admin user. | `string` | `"admin@example.com"` | no |
| <a name="input_wordpress_admin_password"></a> [wordpress\_admin\_password](#input\_wordpress\_admin\_password) | The password of the default wordpress admin user. | `string` | `"techtospeech.com"` | no |
| <a name="input_wordpress_admin_user"></a> [wordpress\_admin\_user](#input\_wordpress\_admin\_user) | The username of the default wordpress admin user. | `string` | `"supervisor"` | no |
| <a name="input_wordpress_memory_limit"></a> [wordpress\_memory\_limit](#input\_wordpress\_memory\_limit) | The memory to allow the Wordpress process to use (in M) | `string` | `"256M"` | no |
| <a name="input_wordpress_subdomain"></a> [wordpress\_subdomain](#input\_wordpress\_subdomain) | The subdomain used for the Wordpress container. | `string` | `"wordpress"` | no |
## Modules

Expand Down
7 changes: 4 additions & 3 deletions ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ resource "aws_ecs_task_definition" "wordpress_container" {
wordpress_admin_password = var.wordpress_admin_password
wordpress_admin_email = var.wordpress_admin_email
site_name = var.site_name
wordpress_memory_limit = var.wordpress_memory_limit
})

runtime_platform {
Expand Down Expand Up @@ -225,7 +226,7 @@ resource "aws_ecs_service" "wordpress_service" {
desired_count = var.launch
# iam_role =
capacity_provider_strategy {
capacity_provider = var.graviton_fargate_enabled ? (contains(local.graviton_fargate_regions_unsupported, data.aws_region.current) ? "FARGATE_SPOT" : "FARGATE") : "FARGATE"
capacity_provider = var.graviton_fargate_enabled ? (contains(local.graviton_fargate_regions_unsupported, data.aws_region.current) ? "FARGATE_SPOT" : "FARGATE") : "FARGATE_SPOT"
weight = "100"
base = "1"
}
Expand All @@ -248,9 +249,9 @@ resource "aws_ecs_cluster" "wordpress_cluster" {

resource "aws_ecs_cluster_capacity_providers" "wordpress_cluster" {
cluster_name = aws_ecs_cluster.wordpress_cluster.name
capacity_providers = [var.graviton_fargate_enabled ? (contains(local.graviton_fargate_regions_unsupported, data.aws_region.current) ? "FARGATE_SPOT" : "FARGATE") : "FARGATE"]
capacity_providers = [var.graviton_fargate_enabled ? (contains(local.graviton_fargate_regions_unsupported, data.aws_region.current) ? "FARGATE_SPOT" : "FARGATE") : "FARGATE_SPOT"]
default_capacity_provider_strategy {
capacity_provider = var.graviton_fargate_enabled ? (contains(local.graviton_fargate_regions_unsupported, data.aws_region.current) ? "FARGATE_SPOT" : "FARGATE") : "FARGATE"
capacity_provider = var.graviton_fargate_enabled ? (contains(local.graviton_fargate_regions_unsupported, data.aws_region.current) ? "FARGATE_SPOT" : "FARGATE") : "FARGATE_SPOT"
weight = "100"
base = "1"
}
Expand Down
2 changes: 2 additions & 0 deletions modules/codebuild/codebuild_files/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ fi
if ! sudo -u www-data wp plugin is-installed wp2static-addon-s3; then
sudo -u www-data wp plugin install /tmp/serverless-wordpress-s3-addon.zip --activate --path=/var/www/html || true
fi
# Update WP_MEMORY_LIMIT
sudo -u www-data wp config set WP_MEMORY_LIMIT ${WP_MEMORY_LIMIT}
# # Update Wordpress options with IP of running container
sudo -u www-data wp option update siteurl "http://${CONTAINER_DNS}" || true
sudo -u www-data wp option update home "http://${CONTAINER_DNS}" || true
Expand Down
3 changes: 2 additions & 1 deletion task-definitions/wordpress.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
{"name": "CONTAINER_DNS_ZONE", "value": "${container_dns_zone}"},
{"name": "WORDPRESS_ADMIN_USER", "value": "${wordpress_admin_user}"},
{"name": "WORDPRESS_ADMIN_PASSWORD", "value": "${wordpress_admin_password}"},
{"name": "WORDPRESS_ADMIN_EMAIL", "value": "${wordpress_admin_email}"}
{"name": "WORDPRESS_ADMIN_EMAIL", "value": "${wordpress_admin_email}"},
{"name": "WP_MEMORY_LIMIT", "value": "${wordpress_memory_limit}"}
],
"essential": true,
"image": "${wordpress_image}",
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ variable "wordpress_admin_email" {
default = "admin@example.com"
}

variable "wordpress_memory_limit" {
type = string
description = "The memory to allow the Wordpress process to use (in M)"
default = "256M"
}

variable "waf_acl_rules" {
type = list(any)
description = "List of WAF rules to apply. Can be customized to apply others created outside of module."
Expand Down