Skip to content

Commit

Permalink
build: docker 개발 환경 설정 (#9)
Browse files Browse the repository at this point in the history
* build: docker 개발 환경 설정

* build: docker-compose.yml 추가
  • Loading branch information
devkimc authored Jun 20, 2023
1 parent e11fef7 commit de95f4f
Show file tree
Hide file tree
Showing 17 changed files with 842 additions and 104 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*.yml
*.p12

HELP.md

### Build ###
.gradle
#!build/
build/*
Expand All @@ -10,6 +10,9 @@ build/*
!**/src/main/**/build/
!**/src/test/**/build/

### Docker ###
db/*

### STS ###
.apt_generated
.classpath
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM openjdk:17.0.2-slim
ARG JAR_FILE=build/libs/practice-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE} jpa-rest.jar
EXPOSE 9090
ENTRYPOINT ["java","-Dspring.profiles.active=dev","-jar","jpa-rest.jar"]
17 changes: 17 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
repository=dkerhater/jpa-rest
os=linux/amd64
tagName=dev

read -p "배포할 버전을 입력하세요:" version

echo "=>>> Gradle 빌드 중입니다...."
./gradlew clean build

echo "=>>> 도커 이미지를 생성 중입니다...."
docker build --platform $os -f Dockerfile.dev -t $repository:$version-$tagName .

echo "=>>> 도커 레포지토리로 이미지를 전송 중입니다...."
docker push $repository:$version-$tagName

echo "🚀 $repository:$version-$tagName 도커 레포지토리에 이미지 전송을 완료했습니다."
51 changes: 51 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: "3"
services:
db:
container_name: jparest-mysql
image: mysql
environment:
MYSQL_DATABASE: jparest
MYSQL_ROOT_PASSWORD: 1#9&3!6@
TZ: Asia/Seoul
volumes:
- ./db/data:/var/lib/mysql:rw
ports:
- "3303:3306"
networks:
- api-network
restart: always
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci

redis:
container_name: jparest-redis
image: redis
ports:
- "6379:6379"
networks:
- api-network
environment:
TZ: Asia/Seoul

api:
image: dkerhater/jpa-rest:0.0.1-dev
restart: always
ports:
- "9090:9090"
depends_on:
- db
- redis
container_name: jpa-rest-api
environment:
TZ: Asia/Seoul
SPRING_PROFILES_ACTIVE: dev
SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/jparest
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: 1#9&3!6@
SPRING_REDIS_HOST: redis
networks:
- api-network

networks:
api-network:
2 changes: 1 addition & 1 deletion src/docs/asciidoc/group.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ifndef::snippets[]
:snippets: ../../../build/generated-snippets
:snippets: ./build/generated-snippets
endif::[]

= Group API
Expand Down
13 changes: 8 additions & 5 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
== APIs

=== User API
* link:user.adoc[바로가기, window=_blank]
* link:user.html[바로가기, window=_blank]

=== Group API
* link:group.adoc[바로가기, window=_blank]
* link:group.html[바로가기, window=_blank]

=== Invite API
* link:invite.adoc[바로가기, window=_blank]
* link:invite.html[바로가기, window=_blank]

=== Restaurant API
* link:restaurant-favorite.adoc[바로가기, window=_blank]
=== Restaurant favorite API
* link:restaurant-favorite.html[바로가기, window=_blank]

=== Restaurant ranking API
* link:restaurant-ranking.html[바로가기, window=_blank]
2 changes: 1 addition & 1 deletion src/docs/asciidoc/invite.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ifndef::snippets[]
:snippets: ../../../build/generated-snippets
:snippets: ./build/generated-snippets
endif::[]

= Invite API
Expand Down
2 changes: 1 addition & 1 deletion src/docs/asciidoc/restaurant-favorite.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ifndef::snippets[]
:snippets: ../../../build/generated-snippets
:snippets: ./build/generated-snippets
endif::[]

= Restaurant API
Expand Down
2 changes: 1 addition & 1 deletion src/docs/asciidoc/restaurant-ranking.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ifndef::snippets[]
:snippets: ../../../build/generated-snippets
:snippets: ./build/generated-snippets
endif::[]

= Restaurant API
Expand Down
2 changes: 1 addition & 1 deletion src/docs/asciidoc/user.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ifndef::snippets[]
:snippets: ../../../build/generated-snippets
:snippets: ./build/generated-snippets
endif::[]

= User API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public class JwtFilterWhiteList {

public static final String[] GET_WHITELIST = new String[]{
"/docs/index.html",
"/docs/user.html",
"/docs/group.html",
"/docs/invite.html",
"/docs/restaurant-favorite.html",
"/docs/restaurant-ranking.html",
"/api/restaurants/ranking/most/save",
"/api/restaurants/ranking/new/save",
};
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/docs/group.html
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ <h3 id="_response_3">RESPONSE</h3>
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2023-06-14 20:16:06 +0900
Last updated 2023-06-19 16:06:07 +0900
</div>
</div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/github.min.css">
Expand Down
25 changes: 18 additions & 7 deletions src/main/resources/static/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ <h1>API 문서</h1>
<li><a href="#_user_api">User API</a></li>
<li><a href="#_group_api">Group API</a></li>
<li><a href="#_invite_api">Invite API</a></li>
<li><a href="#_restaurant_api">Restaurant API</a></li>
<li><a href="#_restaurant_favorite_api">Restaurant favorite API</a></li>
<li><a href="#_restaurant_ranking_api">Restaurant ranking API</a></li>
</ul>
</li>
</ul>
Expand All @@ -466,7 +467,7 @@ <h3 id="_user_api"><a class="link" href="#_user_api">User API</a></h3>
<div class="ulist">
<ul>
<li>
<p><a href="user.adoc" target="_blank" rel="noopener">바로가기</a></p>
<p><a href="user.html" target="_blank" rel="noopener">바로가기</a></p>
</li>
</ul>
</div>
Expand All @@ -476,7 +477,7 @@ <h3 id="_group_api"><a class="link" href="#_group_api">Group API</a></h3>
<div class="ulist">
<ul>
<li>
<p><a href="group.adoc" target="_blank" rel="noopener">바로가기</a></p>
<p><a href="group.html" target="_blank" rel="noopener">바로가기</a></p>
</li>
</ul>
</div>
Expand All @@ -486,17 +487,27 @@ <h3 id="_invite_api"><a class="link" href="#_invite_api">Invite API</a></h3>
<div class="ulist">
<ul>
<li>
<p><a href="invite.adoc" target="_blank" rel="noopener">바로가기</a></p>
<p><a href="invite.html" target="_blank" rel="noopener">바로가기</a></p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_restaurant_api"><a class="link" href="#_restaurant_api">Restaurant API</a></h3>
<h3 id="_restaurant_favorite_api"><a class="link" href="#_restaurant_favorite_api">Restaurant favorite API</a></h3>
<div class="ulist">
<ul>
<li>
<p><a href="restaurant-favorite.adoc" target="_blank" rel="noopener">바로가기</a></p>
<p><a href="restaurant-favorite.html" target="_blank" rel="noopener">바로가기</a></p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_restaurant_ranking_api"><a class="link" href="#_restaurant_ranking_api">Restaurant ranking API</a></h3>
<div class="ulist">
<ul>
<li>
<p><a href="restaurant-ranking.html" target="_blank" rel="noopener">바로가기</a></p>
</li>
</ul>
</div>
Expand All @@ -507,7 +518,7 @@ <h3 id="_restaurant_api"><a class="link" href="#_restaurant_api">Restaurant API<
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2023-06-14 17:30:44 +0900
Last updated 2023-06-19 16:23:57 +0900
</div>
</div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/github.min.css">
Expand Down
Loading

0 comments on commit de95f4f

Please sign in to comment.