diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..9fc9174 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f24c79d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/JMA/.gitignore b/JMA/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/JMA/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/JMA/.idea/.gitignore b/JMA/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/JMA/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/JMA/.idea/misc.xml b/JMA/.idea/misc.xml new file mode 100644 index 0000000..f03c948 --- /dev/null +++ b/JMA/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/JMA/.idea/modules.xml b/JMA/.idea/modules.xml new file mode 100644 index 0000000..055a9cb --- /dev/null +++ b/JMA/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/JMA/.idea/vcs.xml b/JMA/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/JMA/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/JMA/JMA.iml b/JMA/JMA.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/JMA/JMA.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/JMA/src/Main.java b/JMA/src/Main.java new file mode 100644 index 0000000..d5238c9 --- /dev/null +++ b/JMA/src/Main.java @@ -0,0 +1,5 @@ +public class Main { + public static void main(String[] args) { + System.out.println("Hello, World!"); + } +} \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 6ca744c..5d9f22a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,6 +5,9 @@ pipeline { tools { maven 'Maven=3.9.9' } + environment { + IMAGE_NAME = "danbutuc/demo-app:1.0" + } stages { stage("init") { steps { @@ -55,10 +58,13 @@ pipeline { script { echo "deploying" - def dockerCmd = 'docker run -p 3080:3080 -d danbutuc/demo-app:1.0' + def shellCmd = "bash ./server-cmds.sh ${IMAGE_NAME}" + sshagent(['ec2-private-key']) { - sh "ssh -o StrictHostKeyChecking=no ec2-user@34.244.129.21 ${dockerCmd}" - } + sh "scp server-cmds.sh ec2-user@34.244.129.21:/home/ec2-user" + sh "scp docker-compose.yaml ec2-user@34.244.129.21:/home/ec2-user" + sh "ssh -o StrictHostKeyChecking=no ec2-user@34.244.129.21 ${shellCmd}" + } // gv.deployApp() } diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..9e0bd41 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +version: '3.8' +services: + java-maven-app: + image: ${IMAGE} + ports: + - "8080:8080" + + postgres: + image: postgres:15 + ports: + - "5432:5432" + environment: + - POSTGRES_PASSWORD=my-pwd diff --git a/server-cmds.sh b/server-cmds.sh new file mode 100644 index 0000000..6d31f42 --- /dev/null +++ b/server-cmds.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +export IMAGE=$1 +docker-compose -f docker-compose.yaml up --detach +echo "success" \ No newline at end of file