2 Commits

Author SHA1 Message Date
Nana Janashia
4c53fe05e1 Add simple UI 2021-07-12 12:36:08 +02:00
Nana
fab255d0da Configure maven to push to nexus repo 2020-10-28 19:34:12 +01:00
6 changed files with 20 additions and 110 deletions

View File

@@ -1,8 +0,0 @@
FROM openjdk:8-jre-alpine
EXPOSE 8080
COPY ./target/java-maven-app-1.0-SNAPSHOT.jar /usr/app/
WORKDIR /usr/app
ENTRYPOINT ["java", "-jar", "java-maven-app-1.0-SNAPSHOT.jar"]

54
Jenkinsfile vendored
View File

@@ -1,54 +0,0 @@
#!/usr/bin/env groovy
library identifier: 'jenkins-shared-library@master', retriever: modernSCM(
[$class: 'GitSCMSource',
remote: 'https://gitlab.com/nanuchi/jenkins-shared-library.git',
credentialsId: 'gitlab-credentials'
]
)
pipeline {
agent any
tools {
maven 'Maven'
}
environment {
IMAGE_NAME = 'nanajanashia/demo-app:java-maven-2.0'
}
stages {
stage('build app') {
steps {
script {
echo 'building application jar...'
buildJar()
}
}
}
stage('build image') {
steps {
script {
echo 'building docker image...'
buildImage(env.IMAGE_NAME)
dockerLogin()
dockerPush(env.IMAGE_NAME)
}
}
}
stage('deploy') {
steps {
script {
echo 'deploying docker image to EC2...'
def shellCmd = "bash ./server-cmds.sh ${IMAGE_NAME}"
def ec2Instance = "ec2-user@35.180.251.121"
sshagent(['ec2-server-key']) {
sh "scp -o StrictHostKeyChecking=no server-cmds.sh ${ec2Instance}:/home/ec2-user"
sh "scp -o StrictHostKeyChecking=no docker-compose.yaml ${ec2Instance}:/home/ec2-user"
sh "ssh -o StrictHostKeyChecking=no ${ec2Instance} ${shellCmd}"
}
}
}
}
}
}

View File

@@ -1,12 +0,0 @@
version: '3.8'
services:
java-maven-app:
image: ${IMAGE}
ports:
- 8080:8080
postgres:
image: postgres:13
ports:
- 5432:5432
environment:
- POSTGRES_PASSWORD=my-pwd

35
pom.xml
View File

@@ -9,26 +9,31 @@
<version>1.0-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.5.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
</plugin>
</plugins>
</build>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<distributionManagement>
<snapshotRepository>
<id>nexus-snapshots</id>
<url>http://167.99.248.163:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
export IMAGE=$1
docker-compose -f docker-compose.yaml up --detach
echo "success"

View File

@@ -1,16 +0,0 @@
import com.example.Application;
import org.junit.Test;
import static org.junit.Assert.*;
public class AppTest {
@Test
public void testApp() {
Application myApp = new Application();
String result = myApp.getStatus();
assertEquals("OK", result);
}
}