-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from letskuku/letskuku
[18기_이유정] Docker & API 리팩토링 미션 제출합니다.
- Loading branch information
Showing
34 changed files
with
768 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'letskuku' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x ./gradlew | ||
shell: bash | ||
|
||
|
||
- name: Build with Gradle | ||
run: ./gradlew bootJar | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
|
||
|
||
- name : Build Docker Image & Push to Docker Hub | ||
run: | | ||
docker build . -t ${{ secrets.DOCKER_HUB_USERNAME }}/spring-daagn-market-18th | ||
docker build ./proxy -t ${{ secrets.DOCKER_HUB_USERNAME }}/nginx | ||
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/spring-daagn-market-18th | ||
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/nginx | ||
- name: executing remote ssh commands using password | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.KEY }} | ||
script: | | ||
cd /home/ubuntu/ | ||
sudo touch .env | ||
echo "${{ secrets.ENV_VARS }}" | sudo tee .env > /dev/null | ||
sudo touch docker-compose.yml | ||
echo "${{ vars.DOCKER_COMPOSE }}" | sudo tee docker-compose.yml > /dev/null | ||
sudo chmod 666 /var/run/docker.sock | ||
sudo docker rm -f $(docker ps -qa) | ||
sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/spring-daagn-market-18th | ||
sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/nginx | ||
docker-compose -f docker-compose.yml --env-file ./.env up -d | ||
docker image prune -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
HELP.md | ||
.gradle | ||
build/ | ||
gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# open jdk java 17 버전 환경 | ||
FROM openjdk:17 | ||
|
||
# JAR_FILE 변수 정의 | ||
ARG JAR_FILE=/build/libs/*.jar | ||
|
||
# JAR 파일 메인 디렉토리에 복사 | ||
COPY ${JAR_FILE} app.jar | ||
|
||
# 시스템 진입점 정의 | ||
ENTRYPOINT ["java", "-jar", "/app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: "3" | ||
|
||
services: | ||
backend: | ||
image: "letskuku/spring-daagn-market-18th" | ||
env_file: | ||
- .env | ||
ports: | ||
- "8080:8080" | ||
restart: "always" | ||
environment: | ||
- TZ=Asia/Seoul | ||
|
||
nginx: | ||
image: "letskuku/nginx" | ||
ports: | ||
- "80:80" | ||
restart: "always" | ||
depends_on: | ||
- "backend" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM nginx | ||
RUN rm -rf /etc/nginx/conf.d/default.conf | ||
COPY nginx.conf /etc/nginx/conf.d | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
server { | ||
listen 80; | ||
server_name *.compute.amazonaws.com; | ||
|
||
location / { | ||
proxy_pass http://backend:8080; | ||
proxy_set_header Host $host:$server_port; | ||
proxy_set_header X-Forwarded-Host $server_name; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/ceos18/springboot/global/exception/ExceptionController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.ceos18.springboot.global.exception; | ||
|
||
import com.ceos18.springboot.member.exception.MemberException; | ||
import com.ceos18.springboot.post.exception.PostException; | ||
import com.ceos18.springboot.town.exception.TownException; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@Slf4j | ||
@RestControllerAdvice | ||
public class ExceptionController { | ||
|
||
@ExceptionHandler(MemberException.class) | ||
public ResponseEntity<String> catchMemberException(MemberException e) { | ||
log.error(e.getMessage(), e); | ||
return ResponseEntity.status(e.getErrorCode()).body(e.getMessage()); | ||
} | ||
|
||
@ExceptionHandler(PostException.class) | ||
public ResponseEntity<String> catchPostException(PostException e) { | ||
log.error(e.getMessage(), e); | ||
return ResponseEntity.status(e.getErrorCode()).body(e.getMessage()); | ||
} | ||
|
||
@ExceptionHandler(TownException.class) | ||
public ResponseEntity<String> catchTownException(TownException e) { | ||
log.error(e.getMessage(), e); | ||
return ResponseEntity.status(e.getErrorCode()).body(e.getMessage()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.