This repository was archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
[#109] AWS를 활용한 서버 배포 #110
Open
yusok7
wants to merge
5
commits into
main
Choose a base branch
from
feature/jenkins
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 openjdk:11-jre-slim | ||
ARG JAR_FILE=./build/libs/FoodEats-0.0.1-SNAPSHOT.jar | ||
ADD ${JAR_FILE} foodeats.jar | ||
ENTRYPOINT ["java","-jar","/foodeats.jar"] |
This file contains hidden or 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,49 @@ | ||
pipeline { | ||
agent any | ||
options { | ||
timeout(time: 1, unit: 'HOURS') | ||
} | ||
|
||
environment { | ||
SOURCECODE_JENKINS_CREDENTIAL_ID = 'jenkins-github-wh' | ||
SOURCE_CODE_URL = 'https://github.com/f-lab-edu/FoodEats.git' | ||
RELEASE_BRANCH = 'main' | ||
} | ||
|
||
stages { | ||
stage('Init') { | ||
steps { | ||
echo 'clear' | ||
sh 'docker stop $(docker ps -aq)' | ||
sh 'docker rm $(docker ps -aq)' | ||
sh 'docker rmi $(docker images -q)' | ||
deleteDir() | ||
} | ||
} | ||
|
||
stage('clone') { | ||
steps { | ||
git url: "$SOURCE_CODE_URL", | ||
branch: "$RELEASE_BRANCH", | ||
credentialsId: "$SOURCECODE_JENKINS_CREDENTIAL_ID" | ||
sh "ls -al" | ||
} | ||
} | ||
|
||
stage('dockerizing') { | ||
steps { | ||
sh "pwd" | ||
sh "chmod +x ./gradlew" | ||
sh "./gradlew build --stacktrace" | ||
|
||
sh "docker build -t foodeats ." | ||
} | ||
} | ||
|
||
stage('deploy') { | ||
steps { | ||
sh "docker-compose up --build -d" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or 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,29 @@ | ||
version: "3" | ||
|
||
services: | ||
nginx: | ||
image: nginx:1.21.0 | ||
volumes: | ||
- ./nginx/conf.d:/etc/nginx/conf.d | ||
ports: | ||
- "80:80" | ||
depends_on: | ||
- foodeats1 | ||
- foodeats2 | ||
|
||
foodeats1: | ||
image: foodeats | ||
ports: | ||
- "8080:8080" | ||
|
||
foodeats2: | ||
image: foodeats | ||
ports: | ||
- "8081:8080" | ||
|
||
redis: | ||
image: redis:6.2.4 | ||
ports: | ||
- "6379:6379" | ||
|
||
|
This file contains hidden or 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 @@ | ||
upstream foodeats { | ||
server foodeats1:8080; | ||
server foodeats2:8080; | ||
} | ||
|
||
server { | ||
listen 80; | ||
location / { | ||
proxy_pass http://foodeats; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지금 이 순서로 배포를 하게 되면, git에서 클론 받고, gradle 빌드하고, dockerize하고, 다시 docker-compose up이 완료될 때 까지 서비스가 동작하지 않겠네요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 부분 생각치 못했습니다..
해당 문제점에 대한 해결책을 생각해보고 은수님과 스터디시간에 얘기를 나눈 뒤 수정할 수 있도록 하겠습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
멘토님께서 피드백을 주셨듯이,
현재 방법은 배포 시 반드시 서비스를 중단해야하므로 무중단배포가 이뤄지지 않습니다.
이를 해결하기 위해 확실하지는 않지만 2가지 방법을 현재 알아보고 있습니다.
1. nginx를 활용한 방식
2. github actions를 활용한 방식
좀 더 알아보고 내일 멘토링 시간에 들어갈 수 있도록 하겠습니다!