-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
85 additions
and
49 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 |
---|---|---|
@@ -1,52 +1,54 @@ | ||
name: backend-deploy | ||
name: Java CI with Gradle | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
branches: [ "develop" ] | ||
pull_request: | ||
branches: [ "develop" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4.0.0 | ||
- name: checkout working directory | ||
uses: actions/checkout@v3 | ||
|
||
- name: set up Java | ||
uses: actions/setup-java@v3.12.0 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: "11" | ||
distribution: "zulu" | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
shell: bash | ||
java-version: '11' | ||
distribution: 'temurin' | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew bootjar | ||
shell: bash | ||
|
||
- name: Make zip file | ||
run: zip -r ./$GITHUB_SHA.zip . | ||
shell: bash | ||
run: ./gradlew bootJar | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Upload to S3 | ||
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip | ||
|
||
- name: Code Deploy | ||
run: aws deploy create-deployment --application-name bbok-deploy --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name bbok-code-deploy --s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$GITHUB_SHA.zip | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: web image build and push | ||
env: | ||
NAME: ${{ secrets.DOCKER_USERNAME }} | ||
REPO: ${{ secrets.DOCKER_REPO }} | ||
run: | | ||
docker build -t $NAME/$REPO . | ||
docker push $NAME/$REPO | ||
- name: executing remote ssh commands using password | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.KEY }} | ||
script: | | ||
sudo docker rm -f $(docker ps -qa) | ||
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/server-web | ||
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/server-nginx | ||
docker-compose up -d | ||
docker image prune -f |
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
version: '3' | ||
services: | ||
|
||
web: | ||
container_name: web | ||
image: leeseolhui/server-web | ||
expose: | ||
- 8080 | ||
ports: | ||
- 8080:8080 | ||
|
||
nginx: | ||
container_name: nginx | ||
image: leeseolhui/server-nginx | ||
ports: | ||
- 80:80 | ||
depends_on: | ||
- web |
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 openjdk:11 | ||
ARG JAR_FILE=build/libs/*.jar | ||
COPY ${JAR_FILE} server.jar | ||
ENTRYPOINT ["java","-jar","/server.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM nginx | ||
COPY ./nginx/conf.d/nginx.conf /etc/nginx/conf.d |
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,21 @@ | ||
server { | ||
listen 80; | ||
server_name bbok.o-r.kr; | ||
return 301 https://$host$request_uri; | ||
} | ||
|
||
server { | ||
listen 443 ssl; | ||
server_name bbok.o-r.kr; | ||
|
||
ssl_certificate /etc/letsencrypt/live/bbok.o-r.kr/fullchain.pem; | ||
ssl_certificate_key /etc/letsencrypt/live/bbok.o-r.kr/privkey.pem; | ||
|
||
location / { | ||
proxy_pass http://web: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; | ||
} | ||
} |