Skip to content

Commit

Permalink
Merge pull request #1053 from newrelic/pchinthapenta-NR-191162
Browse files Browse the repository at this point in the history
Pchinthapenta nr 191162
  • Loading branch information
Avinash-Sanpala authored Feb 29, 2024
2 parents 9a00b84 + 25a1e37 commit ea40ebd
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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

5 changes: 5 additions & 0 deletions test/deploy/linux/php/docker-templates/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM php:8.2-cli
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
EXPOSE 80
CMD [ "php", "index.php" ]
27 changes: 27 additions & 0 deletions test/deploy/linux/php/docker-templates/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
// Set the content type to text/plain
header('Content-Type: text/plain');

// Function to print "Hello, World!"
function printHelloWorld() {
echo "Hello, World!\n";
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
newrelic_background_job(false);
}
if (ob_get_length()) {
ob_flush();
flush();
}
}

// Print "Hello, World!" initially
printHelloWorld();

// Loop indefinitely
while (true) {
// Sleep for 5 seconds
sleep(5);
// Print "Hello, World!"
printHelloWorld();
}
?>
27 changes: 27 additions & 0 deletions test/manual/definitions/apm/php-agent/docker-php-linux2.json
Original file line number Diff line number Diff line change
@@ -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.small",
"ami_name": "amzn2-ami-hvm-2.0.????????.?-x86_64-gp2",
"user_name": "ec2-user"
}
],
"services": [
{
"id": "wordpress",
"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"]
}
]
}

0 comments on commit ea40ebd

Please sign in to comment.