Compare commits
86 Commits
master
...
feature/je
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd21d95e93 | ||
|
|
9492a348d0 | ||
|
|
a87e8850de | ||
|
|
6123875bc8 | ||
|
|
1f54931484 | ||
|
|
18ecdca204 | ||
|
|
e1dbd4d042 | ||
|
|
36b85d75cc | ||
|
|
c120554c74 | ||
|
|
3e1d99e8d0 | ||
|
|
e71aab1655 | ||
|
|
762a6a9ffb | ||
|
|
e14b7b7012 | ||
|
|
106a7e447e | ||
|
|
b28d6ff9d9 | ||
|
|
4e33b70b24 | ||
|
|
d41bcec12b | ||
|
|
9dadc24128 | ||
|
|
12f88937ab | ||
|
|
8b1aa75d8e | ||
|
|
339109ec86 | ||
|
|
63f6c3d5bb | ||
|
|
ba9f0882ca | ||
|
|
0b043899f9 | ||
|
|
f31394abe3 | ||
|
|
e2633b0888 | ||
|
|
a1b5946b6d | ||
|
|
45817d153a | ||
|
|
0576e0033b | ||
|
|
44cf4ac38c | ||
|
|
04f35ad918 | ||
|
|
686259038b | ||
|
|
1978bd1fc9 | ||
|
|
b262ce98c8 | ||
|
|
24fdad6aaa | ||
|
|
e41eb6433d | ||
|
|
1ce128d916 | ||
|
|
2c6295012f | ||
|
|
48b35c0308 | ||
|
|
80ed88f4be | ||
|
|
f8698fee42 | ||
|
|
eea2109d66 | ||
|
|
a71dd16df8 | ||
|
|
8e3382a0ef | ||
|
|
1d4aac4b5a | ||
|
|
f65d9eb00e | ||
|
|
a026af6e2f | ||
|
|
02aef32659 | ||
|
|
e68743b02d | ||
|
|
ce28529588 | ||
|
|
a0deb05e4e | ||
|
|
126336f79e | ||
|
|
19eeb818ca | ||
|
|
ff51c37f0a | ||
|
|
948fbb8f12 | ||
|
|
679d67b80a | ||
|
|
661a008faa | ||
|
|
9cc6d90fe8 | ||
|
|
61821c6ef7 | ||
|
|
1fa470771d | ||
|
|
9c56ddc553 | ||
|
|
056eca7cf6 | ||
|
|
e637047b84 | ||
|
|
845783dbc6 | ||
|
|
cdacbeeec4 | ||
|
|
1228821c74 | ||
|
|
650570153a | ||
|
|
e5f3bc546b | ||
|
|
99d992ee76 | ||
|
|
273c10f041 | ||
|
|
e0be3b5f9d | ||
|
|
c4cba3ddc6 | ||
|
|
8fb1d04fa8 | ||
|
|
48aa2427b3 | ||
|
|
ed870a0c6b | ||
|
|
28932727d1 | ||
|
|
2ef267a3fb | ||
|
|
05f3e19201 | ||
|
|
5d8d48709e | ||
|
|
fa5460fa44 | ||
|
|
ae9b87113d | ||
|
|
86350ca4e1 | ||
|
|
51edfc3d66 | ||
|
|
c8da404d8b | ||
|
|
18a24797ed | ||
|
|
710e1151f8 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
.idea/*
|
||||
target
|
||||
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
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
Normal file
54
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/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}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
docker-compose.yaml
Normal file
12
docker-compose.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
java-maven-app:
|
||||
image: ${IMAGE}
|
||||
ports:
|
||||
- 8080:8080
|
||||
postgres:
|
||||
image: postgres:13
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=my-pwd
|
||||
21
pom.xml
21
pom.xml
@@ -8,6 +8,27 @@
|
||||
<artifactId>java-maven-app</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<build>
|
||||
<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>
|
||||
</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>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
5
server-cmds.sh
Normal file
5
server-cmds.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export IMAGE=$1
|
||||
docker-compose -f docker-compose.yaml up --detach
|
||||
echo "success"
|
||||
11
src/main/resources/static/index.html
Normal file
11
src/main/resources/static/index.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>MyApp</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome to Java Maven Application</h1>
|
||||
<!-- add image here <img src="" width="" /> -->
|
||||
</body>
|
||||
</html>
|
||||
16
src/test/java/AppTest.java
Normal file
16
src/test/java/AppTest.java
Normal file
@@ -0,0 +1,16 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user