0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

DockerでSpringBootを動かす

Posted at

作りたいものがあるので動かします。

環境

$ sw_vers
ProductVersion:	11.3.1
$ java -version
openjdk version "11.0.11" 2021-04-20
$ gradle --version
Gradle 7.0.2

事前準備

インストール済み!
・VisualStudioCode(以下「VSC」)
・Gradle

作業開始

Spring Boot with Docker
https://spring.io/guides/gs/spring-boot-docker/

Dockerの導入
https://docs.docker.com/get-docker/
「Mac with Apple chip」をインストール

Starting with Spring Initializr
VSC上でSpringinitializrを動かしてプロジェクト作成

ビルド

$ ./gradlew build
BUILD SUCCESSFUL in 17s
$ ls -l build/libs 
build/libs/grapy-0.0.1-SNAPSHOT.jar
$ java -jar build/libs/grapy-0.0.1-SNAPSHOT.jar

ブラウザで確認
http://localhost:8080/
画面上に「Hello Docker World」が表示できた。

dockerfile作成

FROM adoptopenjdk/openjdk11	
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

実行

$ docker build --build-arg JAR_FILE=build/libs/\*.jar -t springio/gs-spring-boot-docker .
$ docker run -p 8080:8080 -t springio/gs-spring-boot-docker

以下で確認できました!
http://localhost:8080/

今回動かしたプログラム
https://github.com/jamcookjapan/grapy

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?