Skip to content

Commit

Permalink
add php82
Browse files Browse the repository at this point in the history
  • Loading branch information
kringkaste committed Feb 20, 2024
1 parent 7b37aa8 commit 9a9d3dc
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 1 deletion.
76 changes: 76 additions & 0 deletions cookbooks/web/recipes/php82.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
include_recipe 'web::ondrej'

package 'nginx'
package 'php8.2-bcmath'
package 'php8.2-cli'
package 'php8.2-curl'
package 'php8.2-fpm'
package 'php8.2-gd'
package 'php8.2-imagick'
package 'php8.2-intl'
package 'php8.2-mbstring'
package 'php8.2-mysql'
package 'php8.2-opcache'
package 'php8.2-soap'
package 'php8.2-xml'
package 'php8.2-zip'

# Delete default configuration files
file_array = ['/etc/nginx/sites-enabled/default',
'/etc/nginx/sites-available/default',
'/etc/php/8.2/fpm/pool.d/www.conf']

file_array.each do |this_file|
file this_file do
action :delete
end
end

# CraftCMS specific changes
replace_or_add 'increase max_execution_time' do
path '/etc/php/8.2/fpm/php.ini'
pattern 'max_execution_time.*'
line 'max_execution_time = 120'
end

replace_or_add 'increase memory_limit' do
path '/etc/php/8.2/fpm/php.ini'
pattern 'memory_limit.*'
line 'memory_limit = 256M'
end

replace_or_add 'increase upload size' do
path '/etc/php/8.2/fpm/php.ini'
pattern 'upload_max_filesize.*'
line 'upload_max_filesize = 1024M'
end

replace_or_add 'increase post size' do
path '/etc/php/8.2/fpm/php.ini'
pattern 'post_max_size.*'
line 'post_max_size = 1024M'
end

remote_directory '/etc/nginx/snippets/' do
source 'snippets'
files_owner 'root'
files_group 'root'
owner 'root'
group 'root'
purge true
end

cookbook_file '/etc/nginx/nginx.conf' do
source 'nginx.conf'
owner 'root'
group 'root'
mode '0644'
end

service 'php8.2-fpm' do
action [:stop, :disable]
end

service 'nginx' do
action [:stop, :disable]
end
42 changes: 42 additions & 0 deletions packer.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,48 @@ build {
}
}

# arm-web-jammy-82
source "amazon-ebs" "arm64-web-jammy-php82" {
ami_groups = ["all"]
ami_name = "codemonauts-arm-web-jammy-php82_${formatdate("YYYY-MM-DD", timestamp())}"
ami_regions = ["eu-west-1"]
instance_type = "t4g.micro"
region = "eu-central-1"
source_ami = "${data.amazon-ami.ubuntu-jammy-arm64.id}"
ssh_username = "ubuntu"
tags = {
Amazon_AMI_Management_Identifier = "arm64_web_jammy_82"
}
}
build {
name = "arm64-web-jammy-82"
sources = ["source.amazon-ebs.arm64-web-jammy-php82"]

provisioner "shell" {
inline = [
"sleep 10",
"sudo apt-get update",
"sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" dist-upgrade",
]
}

provisioner "shell-local" {
command = "mkdir -p .vendor && berks vendor .vendor"
}

provisioner "chef-solo" {
chef_license = "accept"
cookbook_paths = [".vendor"]
run_list = ["common", "unattended-upgrades", "useraccounts", "aws_codedeploy", "aws_ssm", "mozjpeg", "web::php82"]
}

post-processor "amazon-ami-management" {
identifier = "arm64_web_jammy_82"
keep_releases = "1"
regions = ["eu-central-1", "eu-west-1"]
}
}

# arm-web-jammy-81
source "amazon-ebs" "arm64-web-jammy-php81" {
ami_groups = ["all"]
Expand Down
1 change: 0 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

pkgs.mkShell {
buildInputs = with pkgs; [
chefdk
packer
];
shellHook = ''
Expand Down

0 comments on commit 9a9d3dc

Please sign in to comment.