Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions Jenkinsfile

This file was deleted.

30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: '3.8'

services:
nginx:
build: .
container_name: nginx-lb
ports:
- "80:80"
depends_on:
- backend1
- backend2
- backend3

backend1:
image: ghcr.io/benc-uk/python-demoapp
container_name: backend1
expose:
- "5000"

backend2:
image: ghcr.io/benc-uk/python-demoapp
container_name: backend2
expose:
- "5001"

backend3:
image: ghcr.io/benc-uk/python-demoapp
container_name: backend3
expose:
- "5002"
9 changes: 9 additions & 0 deletions dockercompose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

ls /usr/local/bin/

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

docker-compose version
17 changes: 17 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
upstream backend {
server backend1:5000;
server backend2:5001;
server backend3:5002;
}

server {
listen 80;

location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
63 changes: 63 additions & 0 deletions tomcat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
- name: Setup Tomcat
hosts: all
become: yes

tasks:

- name: Download tomcat from dlcdn
get_url:
url: "https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.35/bin/apache-tomcat-10.1.35.tar.gz"
dest: "/root/"

- name: untar the apache file
command: tar -zxvf apache-tomcat-10.1.35.tar.gz

- name: Rename the tomcat
command: mv apache-tomcat-10.1.35 tomcat

- name: Install the latest available Java (OpenJDK)
yum:
name: java-17-amazon-corretto
state: present

- name: Setting the roles in tomcat-users.xml file
template:
src: tomcat-users.xml
dest: /root/tomcat/conf/tomcat-users.xml

- name: Delete two lines in context.xml
template:
src: context.xml
dest: /root/tomcat/webapps/manager/META-INF/context.xml

- name: Create Tomcat systemd Service File
copy:
dest: /etc/systemd/system/tomcat.service
content: |
[Unit]
Description=Apache Tomcat Server
After=network.target

[Service]
User=root
Group=root
Type=forking
Environment="JAVA_HOME=/usr/lib/jvm/jre"
Environment="CATALINA_HOME=/root/tomcat"
ExecStart=/root/tomcat/bin/startup.sh
ExecStop=/root/tomcat/bin/shutdown.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target

- name: Reload systemd
systemd:
daemon_reload: yes

- name: Start tomcat Service
service:
name: tomcat
state: started
enabled: yes
77 changes: 77 additions & 0 deletions tomcatgpt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
- name: Setup Apache Tomcat
hosts: all
become: yes

tasks:

- name: Install Java 17 (Amazon Corretto)
yum:
name: java-17-amazon-corretto
state: present

- name: Download Apache Tomcat
get_url:
url: https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.35/bin/apache-tomcat-10.1.35.tar.gz
dest: /root/apache-tomcat-10.1.35.tar.gz
mode: '0644'

- name: Extract Apache Tomcat
unarchive:
src: /root/apache-tomcat-10.1.35.tar.gz
dest: /root/
remote_src: yes
creates: /root/apache-tomcat-10.1.35

- name: Rename Tomcat directory
command: mv /root/apache-tomcat-10.1.35 /root/tomcat
args:
creates: /root/tomcat

- name: Copy tomcat-users.xml
template:
src: tomcat-users.xml
dest: /root/tomcat/conf/tomcat-users.xml
mode: '0644'

- name: Copy modified context.xml
template:
src: context.xml
dest: /root/tomcat/webapps/manager/META-INF/context.xml
mode: '0644'

- name: Create Tomcat systemd service
copy:
dest: /etc/systemd/system/tomcat.service
mode: '0644'
content: |
[Unit]
Description=Apache Tomcat Server
After=network.target

[Service]
Type=forking
User=root
Group=root

Environment="JAVA_HOME=/usr/lib/jvm/java-17-amazon-corretto"
Environment="CATALINA_HOME=/root/tomcat"
Environment="CATALINA_BASE=/root/tomcat"

ExecStart=/root/tomcat/bin/startup.sh
ExecStop=/root/tomcat/bin/shutdown.sh

Restart=on-failure

[Install]
WantedBy=multi-user.target

- name: Reload systemd daemon
systemd:
daemon_reload: yes

- name: Enable and start Tomcat
systemd:
name: tomcat
state: started
enabled: yes