-
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 #62 from limbs713/limbs713
[19기_임형준] Github Action을 이용한 CI/CD 배포 미션 제출합니다.
- Loading branch information
Showing
5 changed files
with
294 additions
and
20 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,54 @@ | ||
name: CD With Gradle | ||
|
||
on: | ||
push: | ||
branches: ["limbs713"] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up jdk 18 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '18' | ||
distribution: 'temurin' | ||
|
||
- name: Make application.properties | ||
run: | | ||
cd ./src/main/resources | ||
touch ./application.yml | ||
echo "${{ secrets.APPLICATION }}" > ./application.yml | ||
shell: bash | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew bootJar | ||
|
||
## 웹 이미지 빌드 및 도커허브에 push | ||
- name: web docker build and push | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -t limbs713/my-web-image . | ||
docker push limbs713/my-web-image | ||
- name: executing remote ssh commands using password | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.KEY }} | ||
script: | | ||
echo "${{ secrets.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 limbs713/my-web-image | ||
sudo docker pull limbs713/my-db-image | ||
docker-compose -f docker-compose.yml 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
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,28 +1,32 @@ | ||
version: "3" | ||
services: # 이 항목 밑에 실행하려는 컨테이너 들을 정의 ( 컴포즈에서 컨테이너 : 서비스 ) | ||
db: # 서비스 명 | ||
image: mysql:latest # 사용할 이미지 | ||
restart: always | ||
container_name: ceos # 컨테이너 이름 설정 | ||
|
||
services: | ||
db: | ||
image: limbs713/my-db-image:0.0 | ||
ports: | ||
- "3307:3306" # 접근 포트 설정 | ||
- "3306:3306" | ||
environment: # -e 옵션 | ||
- MYSQL_DATABASE=ceos | ||
- MYSQL_ROOT_PASSWORD= "root" # MYSQL 패스워드 설정 옵션 | ||
- MYSQL_DATABASE= rds-everytime | ||
- MYSQL_ROOT_HOST= admin | ||
- MYSQL_ROOT_PASSWORD= 162534Qwe! | ||
- TZ=Asia/Seoul | ||
volumes: | ||
- /Users/Shared/data/mysql-dev:/var/lib/mysql # -v 옵션 (다렉토리 마운트 설정) | ||
- ./db/data:/var/lib/mysql | ||
restart: always | ||
|
||
web: | ||
container_name: spring-everytime | ||
build: src/main/java | ||
image : limbs713/my-web-image | ||
deploy: | ||
resources: | ||
limits: | ||
memory: 512M | ||
ports: | ||
- "8080:8080" | ||
- "3030:3030" | ||
depends_on: | ||
- db | ||
environment: | ||
mysql_host: db | ||
SPRING_DATASOURCE_URL: jdbc:mysql://db-everytime.c5qse0wmogz5.ap-northeast-2.rds.amazonaws.com:3306/rds-everytime?serverTimezone=Asia/Seoul&characterEncoding=UTF-8&xcreateDatabaseIfNotExist=true | ||
SPRING_DATASOURCE_USERNAME: "admin" | ||
SPRING_DATASOURCE_PASSWORD: "162534Qwe!" | ||
restart: always | ||
|
||
volumes: | ||
dbdata: | ||
app: |
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,6 +1,4 @@ | ||
FROM openjdk:18 | ||
ARG JAR_FILE=/build/libs/*.jar | ||
COPY ${JAR_FILE} app.jar | ||
LABEL authors="imhyeongun" | ||
EXPOSE 8080 | ||
ENTRYPOINT ["java","-jar","/app.jar"] |