Skip to content

Commit ea40ebd

Browse files
Merge pull request #1053 from newrelic/pchinthapenta-NR-191162
Pchinthapenta nr 191162
2 parents 9a00b84 + 25a1e37 commit ea40ebd

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
- debug:
3+
msg: Install Docker and PHP
4+
5+
########################################
6+
# RHEL support for Docker installation
7+
########################################
8+
- block:
9+
- name: RHEL - install Docker
10+
package:
11+
name: docker
12+
update_cache: yes
13+
state: present
14+
15+
- name: RHEL - Start docker service
16+
shell: "service docker start"
17+
18+
- name: RHEL - Granting permissions to docker from ec2-user
19+
shell: "usermod -a -G docker ec2-user"
20+
21+
- name: RHEL - Flush user/group permissions change
22+
meta: reset_connection
23+
24+
- name: RHEL - Verify docker service is ready
25+
shell: docker info
26+
register: output
27+
retries: 20
28+
delay: 15
29+
until: output is not failed
30+
31+
when: ansible_pkg_mgr == 'yum'
32+
become: true
33+
34+
- name: Create templates directory
35+
file:
36+
path: /home/ec2-user/templates
37+
state: directory
38+
39+
- name: Copy files to templates directory
40+
synchronize:
41+
src: "{{ item }}"
42+
dest: /home/ec2-user/templates
43+
mode: push
44+
with_fileglob:
45+
- "../../../../docker-templates/*"
46+
become: true
47+
48+
########################################
49+
# PHP installation
50+
########################################
51+
52+
- name: Yum update
53+
shell: yum update
54+
become: true
55+
56+
- name: Install PHP
57+
shell: yum install php -y
58+
become: true
59+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM php:8.2-cli
2+
COPY . /usr/src/myapp
3+
WORKDIR /usr/src/myapp
4+
EXPOSE 80
5+
CMD [ "php", "index.php" ]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
// Set the content type to text/plain
3+
header('Content-Type: text/plain');
4+
5+
// Function to print "Hello, World!"
6+
function printHelloWorld() {
7+
echo "Hello, World!\n";
8+
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
9+
newrelic_background_job(false);
10+
}
11+
if (ob_get_length()) {
12+
ob_flush();
13+
flush();
14+
}
15+
}
16+
17+
// Print "Hello, World!" initially
18+
printHelloWorld();
19+
20+
// Loop indefinitely
21+
while (true) {
22+
// Sleep for 5 seconds
23+
sleep(5);
24+
// Print "Hello, World!"
25+
printHelloWorld();
26+
}
27+
?>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"global_tags": {
3+
"owning_team": "virtuoso",
4+
"Environment": "development",
5+
"Department": "product",
6+
"Product": "virtuoso"
7+
},
8+
"resources": [
9+
{
10+
"id": "doc-php-l2",
11+
"provider": "aws",
12+
"type": "ec2",
13+
"size": "t3.small",
14+
"ami_name": "amzn2-ami-hvm-2.0.????????.?-x86_64-gp2",
15+
"user_name": "ec2-user"
16+
}
17+
],
18+
"services": [
19+
{
20+
"id": "wordpress",
21+
"source_repository": "https://github.com/newrelic/open-install-library.git",
22+
"deploy_script_path": "test/deploy/linux/php/docker-php/redhat/roles",
23+
"port": 80,
24+
"destinations": ["doc-php-l2"]
25+
}
26+
]
27+
}

0 commit comments

Comments
 (0)