From 6d31ffc5f7e3084df5ac1a79396aeec89d1ae078 Mon Sep 17 00:00:00 2001 From: Robert Glenn Date: Mon, 1 Jan 2018 20:55:43 -0800 Subject: [PATCH 1/3] adding a dockerfile and instructions on how to try out the app in a container --- Dockerfile | 24 ++++++++++++++++++++++++ README.md | 7 +++++++ 2 files changed, 31 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3cbeb99 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM gradle:jdk-alpine + +WORKDIR /home/gradle/project + +EXPOSE 8080 + +USER root + +RUN apk update + +ENV GRADLE_USER_HOME /home/gradle/project + +COPY . /home/gradle/project + +RUN gradle build + + +FROM java:jre-alpine + +WORKDIR /home/gradle/project + +COPY --from=0 /home/gradle/project/build/libs/project-0.0.1-SNAPSHOT.jar . + +ENTRYPOINT java -jar project-0.0.1-SNAPSHOT.jar diff --git a/README.md b/README.md index f42a7f3..d1fda97 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,13 @@ You need Java installed. ./gradlew bootRun open http://localhost:8080 +# Try with [Docker](https://www.docker.com/) + +You need Docker installed. + + docker build -t spring-boot-realworld-example-app . + docker run -p 8080:8080 -d spring-boot-realworld-example-app + # Run test The repository contains a lot of test cases to cover both api test and repository test. From 2441e3805bfdc2a8da390df489b6493d0ada4164 Mon Sep 17 00:00:00 2001 From: Robert Glenn Date: Mon, 1 Jan 2018 20:57:20 -0800 Subject: [PATCH 2/3] directing to a prebuilt image hosted on hub.docker --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d1fda97..db0d77a 100644 --- a/README.md +++ b/README.md @@ -38,12 +38,11 @@ You need Java installed. ./gradlew bootRun open http://localhost:8080 -# Try with [Docker](https://www.docker.com/) +# Try it out with [Docker](https://www.docker.com/) You need Docker installed. - docker build -t spring-boot-realworld-example-app . - docker run -p 8080:8080 -d spring-boot-realworld-example-app + docker run -p 8080:8080 -d --name spring-boot-realworld-example-app allthethings/spring-boot-realworld-example-app # Run test From e4092fb140d7be3c860b9aa06830b351828a7fde Mon Sep 17 00:00:00 2001 From: Robert Glenn Date: Tue, 2 Jan 2018 23:25:49 -0800 Subject: [PATCH 3/3] adding docker-compose file --- README.md | 2 +- docker-compose.yml | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yml diff --git a/README.md b/README.md index db0d77a..a9896a0 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ You need Java installed. You need Docker installed. - docker run -p 8080:8080 -d --name spring-boot-realworld-example-app allthethings/spring-boot-realworld-example-app + docker-compose up -d # Run test diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..cf8c538 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3' +services: + spring_boot_realworld_example_app: + image: allthethings/spring-boot-realworld-example-app + ports: + - "8080:8080" + depends_on: + - db + + db: + image: mysql + environment: + - "MYSQL_ALLOW_EMPTY_PASSWORD=true" + ports: + - "3306:3306" +