Skip to content

Commit 08bb63d

Browse files
authored
Add injection of WP_MEMORY_LIMIT into entrypoint (#56)
1 parent 0f14674 commit 08bb63d

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ For any issues relating to this module, [raise an issue against this repo.](http
249249
| <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 |
250250
| <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 |
251251
| <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 |
252+
| <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 |
252253
| <a name="input_wordpress_subdomain"></a> [wordpress\_subdomain](#input\_wordpress\_subdomain) | The subdomain used for the Wordpress container. | `string` | `"wordpress"` | no |
253254
## Modules
254255

ecs.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ resource "aws_ecs_task_definition" "wordpress_container" {
123123
wordpress_admin_password = var.wordpress_admin_password
124124
wordpress_admin_email = var.wordpress_admin_email
125125
site_name = var.site_name
126+
wordpress_memory_limit = var.wordpress_memory_limit
126127
})
127128

128129
runtime_platform {
@@ -225,7 +226,7 @@ resource "aws_ecs_service" "wordpress_service" {
225226
desired_count = var.launch
226227
# iam_role =
227228
capacity_provider_strategy {
228-
capacity_provider = var.graviton_fargate_enabled ? (contains(local.graviton_fargate_regions_unsupported, data.aws_region.current) ? "FARGATE_SPOT" : "FARGATE") : "FARGATE"
229+
capacity_provider = var.graviton_fargate_enabled ? (contains(local.graviton_fargate_regions_unsupported, data.aws_region.current) ? "FARGATE_SPOT" : "FARGATE") : "FARGATE_SPOT"
229230
weight = "100"
230231
base = "1"
231232
}
@@ -248,9 +249,9 @@ resource "aws_ecs_cluster" "wordpress_cluster" {
248249

249250
resource "aws_ecs_cluster_capacity_providers" "wordpress_cluster" {
250251
cluster_name = aws_ecs_cluster.wordpress_cluster.name
251-
capacity_providers = [var.graviton_fargate_enabled ? (contains(local.graviton_fargate_regions_unsupported, data.aws_region.current) ? "FARGATE_SPOT" : "FARGATE") : "FARGATE"]
252+
capacity_providers = [var.graviton_fargate_enabled ? (contains(local.graviton_fargate_regions_unsupported, data.aws_region.current) ? "FARGATE_SPOT" : "FARGATE") : "FARGATE_SPOT"]
252253
default_capacity_provider_strategy {
253-
capacity_provider = var.graviton_fargate_enabled ? (contains(local.graviton_fargate_regions_unsupported, data.aws_region.current) ? "FARGATE_SPOT" : "FARGATE") : "FARGATE"
254+
capacity_provider = var.graviton_fargate_enabled ? (contains(local.graviton_fargate_regions_unsupported, data.aws_region.current) ? "FARGATE_SPOT" : "FARGATE") : "FARGATE_SPOT"
254255
weight = "100"
255256
base = "1"
256257
}

modules/codebuild/codebuild_files/docker-entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ fi
318318
if ! sudo -u www-data wp plugin is-installed wp2static-addon-s3; then
319319
sudo -u www-data wp plugin install /tmp/serverless-wordpress-s3-addon.zip --activate --path=/var/www/html || true
320320
fi
321+
# Update WP_MEMORY_LIMIT
322+
sudo -u www-data wp config set WP_MEMORY_LIMIT ${WP_MEMORY_LIMIT}
321323
# # Update Wordpress options with IP of running container
322324
sudo -u www-data wp option update siteurl "http://${CONTAINER_DNS}" || true
323325
sudo -u www-data wp option update home "http://${CONTAINER_DNS}" || true

task-definitions/wordpress.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
{"name": "CONTAINER_DNS_ZONE", "value": "${container_dns_zone}"},
1515
{"name": "WORDPRESS_ADMIN_USER", "value": "${wordpress_admin_user}"},
1616
{"name": "WORDPRESS_ADMIN_PASSWORD", "value": "${wordpress_admin_password}"},
17-
{"name": "WORDPRESS_ADMIN_EMAIL", "value": "${wordpress_admin_email}"}
17+
{"name": "WORDPRESS_ADMIN_EMAIL", "value": "${wordpress_admin_email}"},
18+
{"name": "WP_MEMORY_LIMIT", "value": "${wordpress_memory_limit}"}
1819
],
1920
"essential": true,
2021
"image": "${wordpress_image}",

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ variable "wordpress_admin_email" {
140140
default = "admin@example.com"
141141
}
142142

143+
variable "wordpress_memory_limit" {
144+
type = string
145+
description = "The memory to allow the Wordpress process to use (in M)"
146+
default = "256M"
147+
}
148+
143149
variable "waf_acl_rules" {
144150
type = list(any)
145151
description = "List of WAF rules to apply. Can be customized to apply others created outside of module."

0 commit comments

Comments
 (0)