Compare commits
49 Commits
feature/je
...
feature/pa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b739431651 | ||
|
|
b78ed1bcf6 | ||
|
|
00154a9e93 | ||
|
|
df13897a25 | ||
|
|
94db5c3efa | ||
|
|
17291abd2e | ||
|
|
d72a06f005 | ||
|
|
0bd74fa092 | ||
|
|
ac5c2b2106 | ||
|
|
ddce6d49ac | ||
|
|
ba406dd3a9 | ||
|
|
997013ad3f | ||
|
|
9fb3cfce01 | ||
|
|
58f1a5cf3e | ||
|
|
ee4f86c17a | ||
|
|
94609f4347 | ||
|
|
b10e682c11 | ||
|
|
12135903ab | ||
|
|
982fdd2438 | ||
|
|
df3a84426f | ||
|
|
b39bdc130f | ||
|
|
7002a942d3 | ||
|
|
5ee75f88dd | ||
|
|
6a2de89154 | ||
|
|
f6850fa35f | ||
|
|
31ecf84171 | ||
|
|
9b90eae493 | ||
|
|
4056c657d3 | ||
|
|
a5ed743178 | ||
|
|
8afb0e62a3 | ||
|
|
2b4921b5c8 | ||
|
|
4f06b352e5 | ||
|
|
c425e899d4 | ||
|
|
15d6bf124f | ||
|
|
b1440f702b | ||
|
|
90bb5d1ddf | ||
|
|
302893976c | ||
|
|
a4a55e133b | ||
|
|
9969d8b2cf | ||
|
|
3e129808aa | ||
|
|
f03d95e413 | ||
|
|
c8f9061ef6 | ||
|
|
6804a58c01 | ||
|
|
5ef50d2628 | ||
|
|
1c02e35f97 | ||
|
|
f298808592 | ||
|
|
a14a9d4f9a | ||
|
|
d267e0d112 | ||
|
|
833dd401b3 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
||||
.idea/*
|
||||
target
|
||||
target/
|
||||
|
||||
@@ -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"]
|
||||
46
Jenkinsfile
vendored
46
Jenkinsfile
vendored
@@ -1,52 +1,26 @@
|
||||
#!/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') {
|
||||
stage('test') {
|
||||
steps {
|
||||
script {
|
||||
echo 'building docker image...'
|
||||
buildImage(env.IMAGE_NAME)
|
||||
dockerLogin()
|
||||
dockerPush(env.IMAGE_NAME)
|
||||
echo "Testing the application..."
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('build') {
|
||||
steps {
|
||||
script {
|
||||
echo "Building the application..."
|
||||
}
|
||||
}
|
||||
}
|
||||
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}"
|
||||
}
|
||||
echo "Deploying the application..."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
21
pom.xml
21
pom.xml
@@ -8,27 +8,6 @@
|
||||
<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>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export IMAGE=$1
|
||||
docker-compose -f docker-compose.yaml up --detach
|
||||
echo "success"
|
||||
@@ -1,11 +0,0 @@
|
||||
<!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>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user