Skip to content

Commit 4060a6a

Browse files
committed
dockerize the app
1 parent 466522c commit 4060a6a

File tree

3 files changed

+58
-20
lines changed

3 files changed

+58
-20
lines changed

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM openjdk:8-jdk-alpine
2+
VOLUME /tmp
3+
EXPOSE 8080
4+
ARG JAR_FILE
5+
COPY ${JAR_FILE} app.jar
6+
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

build.gradle

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
11
buildscript {
2-
ext {
3-
springBootVersion = '2.0.4.RELEASE'
4-
}
5-
repositories {
6-
mavenCentral()
7-
}
8-
dependencies {
9-
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10-
}
2+
ext {
3+
springBootVersion = '2.0.4.RELEASE'
4+
}
5+
repositories {
6+
mavenCentral()
7+
maven {
8+
url "https://plugins.gradle.org/m2/"
9+
}
10+
}
11+
dependencies {
12+
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
13+
classpath('gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.20.1')
14+
}
1115
}
1216

1317
apply plugin: 'java'
1418
apply plugin: 'eclipse'
1519
apply plugin: 'org.springframework.boot'
1620
apply plugin: 'io.spring.dependency-management'
21+
apply plugin: 'com.palantir.docker'
1722

1823
group = 'com.streaming'
1924
version = '0.0.1-SNAPSHOT'
2025
sourceCompatibility = 1.8
2126

2227
repositories {
23-
mavenCentral()
28+
mavenCentral()
2429
}
2530

26-
2731
dependencies {
28-
compile('org.springframework.boot:spring-boot-starter-data-jpa')
29-
compile('org.springframework.boot:spring-boot-starter-security')
30-
compile('org.springframework.boot:spring-boot-starter-web')
31-
compile("com.auth0:java-jwt:3.4.0")
32-
compile ("io.springfox:springfox-swagger2:2.9.2")
33-
compile ("io.springfox:springfox-swagger-ui:2.9.2")
34-
compile ("io.springfox:springfox-spring-web:2.9.2")
35-
runtime('mysql:mysql-connector-java')
36-
testCompile('org.springframework.boot:spring-boot-starter-test')
32+
compile('org.springframework.boot:spring-boot-starter-data-jpa')
33+
compile('org.springframework.boot:spring-boot-starter-security')
34+
compile('org.springframework.boot:spring-boot-starter-web')
35+
compile("com.auth0:java-jwt:3.4.0")
36+
compile("io.springfox:springfox-swagger2:2.9.2")
37+
compile("io.springfox:springfox-swagger-ui:2.9.2")
38+
compile("io.springfox:springfox-spring-web:2.9.2")
39+
runtime('mysql:mysql-connector-java')
40+
testCompile('org.springframework.boot:spring-boot-starter-test')
3741
}
42+
43+
docker {
44+
dependsOn build
45+
name "${project.group}/${bootJar.baseName}"
46+
files bootJar.archivePath
47+
buildArgs(['JAR_FILE': "${bootJar.archiveName}"])
48+
}

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: '3'
2+
3+
services:
4+
docker-mysql:
5+
image: mysql:latest
6+
environment:
7+
- MYSQL_ROOT_PASSWORD=
8+
- MYSQL_DATABASE=live-streaming
9+
- MYSQL_PASSWORD=root
10+
spring-boot-jpa-docker-webapp:
11+
image: com.streaming/live-streaming
12+
depends_on:
13+
- docker-mysql
14+
ports:
15+
- 8080:8080
16+
environment:
17+
- DATABASE_HOST=docker-mysql
18+
- DATABASE_USER=root
19+
- DATABASE_PASSWORD=
20+
- DATABASE_NAME=live-streaming
21+
- DATABASE_PORT=3306

0 commit comments

Comments
 (0)