Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Widget Connector
urlhttp://youtube.com/watch?v=Pv8iUi4-FOA

Info
  1. 사전 조건
    1. Azure VM & 환경설정 이 필요합니다.
  2. Git 프로젝트를 fork 합니다.
  3. Azure VM에 git clone 합니다.
  4. mvnw 빌드 합니다.
  5. redis container를 실행합니다.
  6. Spring boot 어플리케이션을 실행 합니다.
  7. curl로 호출해 봅니다.

Image Removed

Image Removed

    1. SRRD DevEnv on Desktop PC 환경설정을 검토 합니다.


SWRS Docker 배경지식


Info

https://github.com/spring-academy/reactive-link-shortener-sample-app

Info

Table of Contents


1. Git Fork

Image Added

Image Added

2. Git Clone

Code Block
titlegit clone https://github.com/Sanses/reactive-link-shortener-sample-app.git
C:\Users\sanse\workspace>git
Code Block
[root@workspace-vm workspace]# git clone https://github.com/Sanses/sanse-reactive-link-shortener-sample-app.git
Cloning into 'sanse-reactive-link-shortener-sample-app'...
remote: Enumerating objects: 7911, done.
remote: Counting objects: 100% (7911/7911), done.
remote: Compressing objects: 100% (6710/6710), done.
remote: Total 7973 (delta 172), reused 450 (delta 30), pack-reused 062
Unpacking objects: 100% (7973/79)73), 57.02 KiB | 70.00 KiB/s, done.
[root@workspace-vm workspace]# 
[root@workspace-vm workspace]# 
[root@workspace-vm workspace]# ls
sanse-reactive-link-shortener-sample-app
[root@workspace-vm workspace]# cd sanse-reactive-link-shortener-sample-app/
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# 
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# 
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# ls -al
total 40
drwxr-xr-x. 6 root root  172 May  7 12:17 .
drwxr-xr-x. 3 root root   54 May  7 12:17 ..
drwxr-xr-x. 8 root root  163 May  7 12:17 .git
-rw-r--r--. 1 root root  268 May  7 12:17 .gitignore
-rw-r--r--. 1 root root   77 May  7 12:17 lombok.config
drwxr-xr-x. 3 root root   21 May  7 12:17 .mvn
-rwxr-xr-x. 1 root root 9113 May  7 12:17 mvnw
-rw-r--r--. 1 root root 5810 May  7 12:17 mvnw.cmd
-rw-r--r--. 1 root root 3116 May  7 12:17 pom.xml
-rw-r--r--. 1 root root  951 May  7 12:17 README.md
drwxr-xr-x. 4 root root   30 May  7 12:17 src
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# 

C:\Users\sanse\workspace>dir
 Volume in drive C is Windows
 Volume Serial Number is 24E4-A55B

 Directory of C:\Users\sanse\workspace

2020-09-06  오후 09:33    <DIR>          .
2020-09-06  오후 09:33    <DIR>          ..
2020-09-06  오후 09:33    <DIR>          reactive-link-shortener-sample-app
               0 File(s)              0 bytes
               3 Dir(s)  93,214,756,864 bytes free

3. Build Application

Code Block
titlemvnw clean package
C:\Users\sanse\workspace\reactive-link-shortener-sample-app>mvnw clean
Found "C:\Users\sanse\workspace\reactive-link-shortener-sample-app\.mvn\wrapper\maven-wrapper.jar"
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.example:demo >--------------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ demo ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.316 s
[INFO] Finished at: 2020-09-06T21:36:09+09:00
[INFO] ------------------------------------------------------------------------

C:\Users\sanse\workspace\reactive-link-shortener-sample-app>mvnw package
Found "C:\Users\sanse\workspace\reactive-link-shortener-sample-app\.mvn\wrapper\maven-wrapper.jar"
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.example:demo >--------------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ demo ---
Code Block
## 프로젝트 빌드
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# ./mvnw clean package
[INFO] Scanning for projects...
~~~~~~~~~~~~~~~~~ 생략 ~~~~~~~~~~~~~~~~~~
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0302:2311 min
[INFO] Finished at: 20192020-0509-07T12:24:56Z06T21:38:34+09:00
[INFO] ------------------------------------------------------------------------

4. Run Redis Container

Code Block
languagebash
themeMidnight
titledocker run -d -p 6379:6379 --name redis redis
linenumberstrue
C:\Users\sanse\workspace\
Code Block
## Redis Container 실행
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# dockerapp>docker run -d -p 6379:6379 --name redis redis
Unable to find image 'redis:latest' locally
latest: Pulling from library/redis
27833a3ba0a5bf5952930446: Pull complete 
cde8019a4b43911b8422b695: Pull complete 
97a473b37fb2093b947e0ade: Pull complete 
c6fe0dfbb7e3c7616728f575: Pull complete 
39c8f5ba124061a55f107028: Pull complete 
cfbdd870cf750ee3e0cb4e07: Pull complete 
Digest: sha256:000339fb57e0ddf2d48d72f3341e47a8ca3b1beae9bdcb25a96323095b72a79b933c6c01829165885ea8468d87f71127b1cb76a711311e6c63708097e92ee3d1
Status: Downloaded newer image for redis:latest
8ebd440fdd83ac7cc6c55cc278aedf690420bc63cf3bb5864db12ed78247e0e8a1bb2185039c29b801c57ee99644c3179481b33dd73d58fcde90bcf2099a89dc
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# 
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                    NAMES
8ebd440fdd83        redis               "docker-entrypoint.s   About a minute ago   Up About a minute   0.0.0.0:6379->6379/tcp   redis
[root@workspace-vm sanse- 

5. Run Application

Code Block
titlejava -jar demo-0.0.1-SNAPSHOT.jar
C:\Users\sanse\workspace\reactive-link-shortener-sample-app]# 
Code Block
## 어플리케이션 실행
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# java -jar target/\target>java -jar demo-0.0.1-SNAPSHOT.jar &
[1] 39968
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# 
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.0.RELEASE)

20192020-0509-0706 1221:2943:28.572  INFO 39968 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication v0.0.1-SNAPSHOT on workspace-vm with PID 39968 (/root/workspace/sanse-reactive-link-shortener-sample-app/target/demo-0.0.1-SNAPSHOT.jar started by root in /root/workspace/sanse-reactive-link-shortener-sample-app)
2019-05-07 12:29:28.578  INFO 39968 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2019-05-07 12:29:29.347  INFO 39968 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2019-05-07 12:29:29.350  INFO 39968 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-05-07 12:29:29.378  INFO 39968 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 15ms. Found 0 repository interfaces.
2019-05-07 12:29:29.783  WARN 3996831.839  WARN 11288 --- [           main] reactor.netty.tcp.TcpResources           : [http] resources will use the default LoopResources: DefaultLoopResources {prefix=reactor-http, daemon=true, selectCount=4, workerCount=4}
20192020-0509-0706 1221:2943:2931.783855  WARN 3996811288 --- [           main] reactor.netty.tcp.TcpResources           : [http] resources will use the default ConnectionProvider: PooledConnectionProvider {name=http, poolFactory=reactor.netty.resources.ConnectionProvider$$Lambda$196ConnectionProvider$$Lambda$198/146305349@6483f5ae233021551@76b10754}
20192020-0509-0706 1221:2943:3137.012550  INFO 3996811288 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port(s): 8080
20192020-0509-0706 1221:2943:3137.016566  INFO 3996811288 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 311.06739 seconds (JVM running for 313.582)

[root@workspace-vm sanse-reactive-link-shortener-sample-app]# 57)

6. Call Api

Code Block
languagebash
themeMidnight
titlecurl -XPOST http://localhost:8080/link -H "Content-Type: application/json" -d "{\"link\":\"http://wiki.iisanse.com\"}"
linenumberstrue
C:\Users\sanse\workspace\
Code Block
## 어플리케이션 호출
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# curlapp>curl -XPOST http://localhost:8080/link -H "Content-Type: application/json" -d '"{\"link\":\"http://wiki.thesanseiisanse.com"}'
2019-05-07 12:30:14.689  INFO 39968 --- [-server-epoll-6] io.lettuce.core.EpollProvider            : Starting with epoll library
2019-05-07 12:30:14.691  INFO 39968 --- [-server-epoll-6] io.lettuce.core.KqueueProvider           : Starting without optional kqueue library\"}"
{"shortenedLink":"http://localhost:8080/kRqbyeruEadd"}
Code Block
## 어플리케이션 종료
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# ps -eaf | grep java
root      39968  34937  0 12:29 pts/0    00:00:08 java -jar target/demo-0.0.1-SNAPSHOT.jar
root      41676  34937  0 12:47 pts/0    00:00:00 grep --color=auto java
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# kill -9 39968
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# 
[1]+  Killed                  java -jar target/demo-0.0.1-SNAPSHOT.jar
[root@workspace-vm sanse-reactive-link-shortener-sample-app]# 
[root@workspace-vm sanse-reactive-link-shortener-sample-app]#