Skip to content

Commit 08891fa

Browse files
committed
Initial commit
0 parents  commit 08891fa

File tree

61 files changed

+2163
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2163
-0
lines changed

.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**
5+
!**/src/test/**
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
30+
### VS Code ###
31+
.vscode/
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
https://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
20+
import java.io.File;
21+
import java.io.FileInputStream;
22+
import java.io.FileOutputStream;
23+
import java.io.IOException;
24+
import java.net.URL;
25+
import java.nio.channels.Channels;
26+
import java.nio.channels.ReadableByteChannel;
27+
import java.util.Properties;
28+
29+
public class MavenWrapperDownloader {
30+
31+
/**
32+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
33+
*/
34+
private static final String DEFAULT_DOWNLOAD_URL =
35+
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
36+
37+
/**
38+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
39+
* use instead of the default one.
40+
*/
41+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
42+
".mvn/wrapper/maven-wrapper.properties";
43+
44+
/**
45+
* Path where the maven-wrapper.jar will be saved to.
46+
*/
47+
private static final String MAVEN_WRAPPER_JAR_PATH =
48+
".mvn/wrapper/maven-wrapper.jar";
49+
50+
/**
51+
* Name of the property which should be used to override the default download url for the wrapper.
52+
*/
53+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
54+
55+
public static void main(String args[]) {
56+
System.out.println("- Downloader started");
57+
File baseDirectory = new File(args[0]);
58+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
59+
60+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
61+
// wrapperUrl parameter.
62+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
63+
String url = DEFAULT_DOWNLOAD_URL;
64+
if(mavenWrapperPropertyFile.exists()) {
65+
FileInputStream mavenWrapperPropertyFileInputStream = null;
66+
try {
67+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
68+
Properties mavenWrapperProperties = new Properties();
69+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
70+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
71+
} catch (IOException e) {
72+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
73+
} finally {
74+
try {
75+
if(mavenWrapperPropertyFileInputStream != null) {
76+
mavenWrapperPropertyFileInputStream.close();
77+
}
78+
} catch (IOException e) {
79+
// Ignore ...
80+
}
81+
}
82+
}
83+
System.out.println("- Downloading from: : " + url);
84+
85+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
86+
if(!outputFile.getParentFile().exists()) {
87+
if(!outputFile.getParentFile().mkdirs()) {
88+
System.out.println(
89+
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
90+
}
91+
}
92+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
93+
try {
94+
downloadFileFromURL(url, outputFile);
95+
System.out.println("Done");
96+
System.exit(0);
97+
} catch (Throwable e) {
98+
System.out.println("- Error downloading");
99+
e.printStackTrace();
100+
System.exit(1);
101+
}
102+
}
103+
104+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
105+
URL website = new URL(urlString);
106+
ReadableByteChannel rbc;
107+
rbc = Channels.newChannel(website.openStream());
108+
FileOutputStream fos = new FileOutputStream(destination);
109+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
110+
fos.close();
111+
rbc.close();
112+
}
113+
114+
}

.mvn/wrapper/maven-wrapper.jar

47.2 KB
Binary file not shown.

.mvn/wrapper/maven-wrapper.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Spring Boot Deploy App
2+
========================
3+
During learning Kubernetes or Docker Swarm, I always faced a problem which image should I use for deployment.
4+
Most often I used NGINX or just a simple Spring Boot up generated from a scratch. Each time the same, blank boring
5+
landing page. Here is my simple tiny application dashboard based on Spring Boot and Bootstrap allows you to test
6+
deployment in a few various versions, with a few customized parameters.
7+
8+
Docker Image
9+
------------
10+
[![](https://images.microbadger.com/badges/image/slydeveloper/spring-boot-deploy-app.svg)](https://microbadger.com/images/slydeveloper/spring-boot-admin "Get your own image badge on microbadger.com")
11+
[![](https://images.microbadger.com/badges/version/slydeveloper/spring-boot-deploy-app.svg)](https://microbadger.com/images/slydeveloper/spring-boot-admin "Get your own version badge on microbadger.com")
12+
13+
Info
14+
----
15+
* Name: `slydeveloper/spring-boot-deploy-app`
16+
* Version: `latest`,`1.0`
17+
* [Docker Hub](https://hub.docker.com/r/slydeveloper/spring-boot-deploy-app/)
18+
19+
Details
20+
--------
21+
* Image based on `openjdk:11.0.1-jre-slim`
22+
* Spring Boot version: `2.1.6.RELEASE`
23+
* Default port: `8080`
24+
* URL: `http://localhost:8080/`
25+
* Health check URL - `http://localhost:8080/actuator/health`
26+
* Actuator info URL - `http://localhost:8080/actuator/info`
27+
28+
Usage
29+
-----
30+
* `docker run -d -p 8080:8080 --name spring-boot-deploy-app slydeveloper/spring-boot-deploy-app`
31+
* `docker run -d -p 8080:8080 -e SPRING_BOOT_DEPLOY_APP_TITLE="My Spring Boot Deploy App Example" -e SPRING_BOOT_DEPLOY_APP_NAME="My Spring Boot Deploy App Title" --name spring-boot-deploy-app slydeveloper/spring-boot-deploy-app`
32+
33+
Screenshot
34+
-----
35+
![Screen](screen.png)

docker/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DOCKER_IMAGE_NAME=slydeveloper/spring-boot-deploy-app
2+
DOCKER_IMAGE_VERSION=$(mvn -f ../pom.xml -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)

docker/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# build stage
2+
FROM maven:3.6.1-jdk-11-slim AS build-stage
3+
4+
LABEL maintainer="[email protected]"
5+
6+
COPY pom.xml /tmp/
7+
8+
COPY src /tmp/src/
9+
10+
WORKDIR /tmp/
11+
12+
RUN mvn clean package
13+
14+
# run stage
15+
FROM openjdk:11.0.1-jre-slim as run-stage
16+
17+
LABEL maintainer="[email protected]"
18+
19+
COPY --from=build-stage /tmp/target/*.jar /opt/app.jar
20+
21+
EXPOSE 8080
22+
23+
WORKDIR /opt
24+
25+
ENTRYPOINT ["java","-jar","app.jar"]

docker/docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: '3'
2+
3+
services:
4+
sb-deploy-app-build:
5+
build:
6+
context: ../
7+
dockerfile: ./docker/Dockerfile
8+
ports:
9+
- "8080:8080"
10+
container_name: spring_boot_deploy_app_dev
11+
image: ${DOCKER_IMAGE_NAME}
12+
environment:
13+
- SPRING_BOOT_DEPLOY_APP_TITLE=Spring Boot Deploy App Github
14+
- SPRING_BOOT_DEPLOY_APP_NAME=Spring Boot Deploy App Github

docker/docker_build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
source .env
4+
5+
docker-compose down
6+
7+
echo Building image: $DOCKER_IMAGE_NAME
8+
9+
docker-compose build
10+
11+
docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")
12+
13+
docker tag $DOCKER_IMAGE_NAME:latest $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_VERSION
14+
15+
docker images $DOCKER_IMAGE_NAME

docker/docker_build_and_publish.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
source ./docker_build.sh
4+
5+
docker push $DOCKER_IMAGE_NAME:latest
6+
7+
docker push $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_VERSION

docker/docker_build_and_run.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
source ./docker_build.sh
4+
5+
docker-compose up
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3'
2+
3+
services:
4+
sb-deploy-app-example:
5+
ports:
6+
- "8080:8080"
7+
container_name: spring_boot_deploy_app_example
8+
image: slydeveloper/spring-boot-deploy-app:1.0
9+
environment:
10+
- SPRING_BOOT_DEPLOY_APP_TITLE=My Spring Boot Deploy App Example
11+
- SPRING_BOOT_DEPLOY_APP_NAME=My Spring Boot Deploy App Title

example_docker_usage/docker_start.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
docker-compose down
4+
5+
docker-compose up --build

example_docker_usage/docker_stop.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker-compose down

0 commit comments

Comments
 (0)