From 495fbcc311fc1a4aa261b638c9729f6be9a3110d Mon Sep 17 00:00:00 2001 From: pchinthapenta Date: Tue, 27 Feb 2024 19:06:22 +0530 Subject: [PATCH 1/4] feat:Added Docker file and Sample application file for PHP-Docker deploy config --- .../redhat/roles/configure/tasks/main.yml | 59 +++++++++++++++++++ .../linux/php/docker-templates/Dockerfile | 5 ++ .../linux/php/docker-templates/index.php | 22 +++++++ .../apm/php-agent/docker-php-linux2.json | 27 +++++++++ 4 files changed, 113 insertions(+) create mode 100644 test/deploy/linux/php/docker-php/redhat/roles/configure/tasks/main.yml create mode 100755 test/deploy/linux/php/docker-templates/Dockerfile create mode 100755 test/deploy/linux/php/docker-templates/index.php create mode 100644 test/manual/definitions/apm/php-agent/docker-php-linux2.json diff --git a/test/deploy/linux/php/docker-php/redhat/roles/configure/tasks/main.yml b/test/deploy/linux/php/docker-php/redhat/roles/configure/tasks/main.yml new file mode 100644 index 000000000..9c0fbd70e --- /dev/null +++ b/test/deploy/linux/php/docker-php/redhat/roles/configure/tasks/main.yml @@ -0,0 +1,59 @@ +--- +- debug: + msg: Install Docker and PHP + +######################################## +# RHEL support for Docker installation +######################################## +- block: + - name: RHEL - install Docker + package: + name: docker + update_cache: yes + state: present + + - name: RHEL - Start docker service + shell: "service docker start" + + - name: RHEL - Granting permissions to docker from ec2-user + shell: "usermod -a -G docker ec2-user" + + - name: RHEL - Flush user/group permissions change + meta: reset_connection + + - name: RHEL - Verify docker service is ready + shell: docker info + register: output + retries: 20 + delay: 15 + until: output is not failed + + when: ansible_pkg_mgr == 'yum' + become: true + +- name: Create templates directory + file: + path: /home/ec2-user/templates + state: directory + +- name: Copy files to templates directory + synchronize: + src: "{{ item }}" + dest: /home/ec2-user/templates + mode: push + with_fileglob: + - "../../../../docker-templates/*" + become: true + +######################################## +# PHP installation +######################################## + +- name: Yum update + shell: yum update + become: true + +- name: Install PHP + shell: yum install php -y + become: true + diff --git a/test/deploy/linux/php/docker-templates/Dockerfile b/test/deploy/linux/php/docker-templates/Dockerfile new file mode 100755 index 000000000..a662f619c --- /dev/null +++ b/test/deploy/linux/php/docker-templates/Dockerfile @@ -0,0 +1,5 @@ +FROM php:8.2-cli +COPY . /usr/src/myapp +WORKDIR /usr/src/myapp +EXPOSE 88 +CMD [ "php", "index.php" ] \ No newline at end of file diff --git a/test/deploy/linux/php/docker-templates/index.php b/test/deploy/linux/php/docker-templates/index.php new file mode 100755 index 000000000..02ed70dac --- /dev/null +++ b/test/deploy/linux/php/docker-templates/index.php @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/test/manual/definitions/apm/php-agent/docker-php-linux2.json b/test/manual/definitions/apm/php-agent/docker-php-linux2.json new file mode 100644 index 000000000..3d757fa3c --- /dev/null +++ b/test/manual/definitions/apm/php-agent/docker-php-linux2.json @@ -0,0 +1,27 @@ +{ + "global_tags": { + "owning_team": "virtuoso", + "Environment": "development", + "Department": "product", + "Product": "virtuoso" + }, + "resources": [ + { + "id": "doc-php-l2", + "provider": "aws", + "type": "ec2", + "size": "t3.medium", + "ami_name": "amzn2-ami-hvm-2.0.????????.?-x86_64-gp2", + "user_name": "ec2-user" + } + ], + "services": [ + { + "id": "wordpress", + "local_source_path": "/mnt/deployer", + "deploy_script_path": "test/deploy/linux/php/docker-php/redhat/roles", + "port": 80, + "destinations": ["doc-php-l2"] + } + ] +} From 2da06519e60aee32e414e180c51f6e2cf150fb4c Mon Sep 17 00:00:00 2001 From: pchinthapenta Date: Thu, 29 Feb 2024 13:13:57 +0530 Subject: [PATCH 2/4] chore: Updated resource size for docker-php --- test/manual/definitions/apm/php-agent/docker-php-linux2.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/manual/definitions/apm/php-agent/docker-php-linux2.json b/test/manual/definitions/apm/php-agent/docker-php-linux2.json index 3d757fa3c..a18fb787d 100644 --- a/test/manual/definitions/apm/php-agent/docker-php-linux2.json +++ b/test/manual/definitions/apm/php-agent/docker-php-linux2.json @@ -10,7 +10,7 @@ "id": "doc-php-l2", "provider": "aws", "type": "ec2", - "size": "t3.medium", + "size": "t3.small", "ami_name": "amzn2-ami-hvm-2.0.????????.?-x86_64-gp2", "user_name": "ec2-user" } From 964fe66a96777e6fad80dc77cd2a73d68e1823be Mon Sep 17 00:00:00 2001 From: pchinthapenta Date: Thu, 29 Feb 2024 19:49:36 +0530 Subject: [PATCH 3/4] chore: Updated sample application and Dockerfile for docker-php deploy config --- test/deploy/linux/php/docker-templates/Dockerfile | 2 +- test/deploy/linux/php/docker-templates/index.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/test/deploy/linux/php/docker-templates/Dockerfile b/test/deploy/linux/php/docker-templates/Dockerfile index a662f619c..78d1aaa3a 100755 --- a/test/deploy/linux/php/docker-templates/Dockerfile +++ b/test/deploy/linux/php/docker-templates/Dockerfile @@ -1,5 +1,5 @@ FROM php:8.2-cli COPY . /usr/src/myapp WORKDIR /usr/src/myapp -EXPOSE 88 +EXPOSE 80 CMD [ "php", "index.php" ] \ No newline at end of file diff --git a/test/deploy/linux/php/docker-templates/index.php b/test/deploy/linux/php/docker-templates/index.php index 02ed70dac..13a3740ce 100755 --- a/test/deploy/linux/php/docker-templates/index.php +++ b/test/deploy/linux/php/docker-templates/index.php @@ -5,8 +5,13 @@ // Function to print "Hello, World!" function printHelloWorld() { echo "Hello, World!\n"; - ob_flush(); - flush(); + if (extension_loaded('newrelic')) { // Ensure PHP agent is available + newrelic_background_job(false); + } + if (ob_get_length()) { + ob_flush(); + flush(); + } } // Print "Hello, World!" initially From 25a1e375f4323bca028deb07a48b9117e98b503b Mon Sep 17 00:00:00 2001 From: pchinthapenta Date: Thu, 29 Feb 2024 22:40:11 +0530 Subject: [PATCH 4/4] chore: Updated sample application and Dockerfile for docker-php deploy config --- test/manual/definitions/apm/php-agent/docker-php-linux2.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/manual/definitions/apm/php-agent/docker-php-linux2.json b/test/manual/definitions/apm/php-agent/docker-php-linux2.json index a18fb787d..11f977e54 100644 --- a/test/manual/definitions/apm/php-agent/docker-php-linux2.json +++ b/test/manual/definitions/apm/php-agent/docker-php-linux2.json @@ -18,7 +18,7 @@ "services": [ { "id": "wordpress", - "local_source_path": "/mnt/deployer", + "source_repository": "https://github.com/newrelic/open-install-library.git", "deploy_script_path": "test/deploy/linux/php/docker-php/redhat/roles", "port": 80, "destinations": ["doc-php-l2"]