Compare commits
2 Commits
feature/je
...
feature/de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c53fe05e1 | ||
|
|
fab255d0da |
@@ -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
54
Jenkinsfile
vendored
@@ -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}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
35
pom.xml
@@ -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>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export IMAGE=$1
|
||||
docker-compose -f docker-compose.yaml up --detach
|
||||
echo "success"
|
||||
@@ -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