-
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 #45 from yeni-choi/yeni-choi
[18기_�최예원] Github Action을 이용한 CI/CD 배포 미션 제출합니다.
- Loading branch information
Showing
8 changed files
with
352 additions
and
45 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,61 @@ | ||
name: Deploy Development Server | ||
|
||
on: | ||
push: | ||
branches: [ "yeni-choi" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
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' | ||
|
||
## gradle build | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x ./gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build -x test | ||
|
||
## 웹 이미지 빌드 및 도커허브에 push | ||
- name: web docker build and push | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -t yeniwithchoi/ceos-karrot . | ||
docker push yeniwithchoi/ceos-karrot | ||
docker build -f dockerfile-nginx -t yeniwithchoi/ceos-nginx . | ||
docker push yeniwithchoi/ceos-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/ | ||
## .env 파일을 생성합니다. | ||
sudo touch .env | ||
echo "${{ secrets.ENV_VARS }}" | sudo tee .env > /dev/null | ||
## docker-compose를 실행합니다. | ||
sudo chmod 666 /var/run/docker.sock | ||
sudo docker rm -f $(docker ps -qa) | ||
sudo docker pull yeniwithchoi/ceos-karrot | ||
sudo docker pull yeniwithchoi/ceos-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
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,40 +1,23 @@ | ||
version: "3" | ||
|
||
services: # 컨테이너 설정 | ||
db: | ||
container_name: db # MySQL 컨테이너의 이름 지정 | ||
image: mysql:5.7 # 컨테이너에서 사용하는 base image 지정 | ||
env_file: .env | ||
environment: | ||
MYSQL_ROOT_HOST: '%' | ||
MYSQL_ROOT_PASSWORD: mysql | ||
expose: | ||
- 3306 | ||
volumes: # -v 옵션과 동일 | ||
- dbdata:/var/lib/mysql | ||
ports: # -p 옵션과 동일 | ||
- 3308:3306 | ||
# restart: always # 컨테이너 다운 시 재시작하라는 명령어 | ||
version: '3' | ||
services: | ||
|
||
web: | ||
container_name: web | ||
build: . #image를 DockerFile 기반으로 사용 | ||
image: yeniwithchoi/ceos-karrot | ||
env_file: | ||
- .env | ||
expose: | ||
- 8080 | ||
ports: | ||
- "8080:8080" | ||
depends_on: # database service가 실행된 이후에 실행 | ||
- db | ||
env_file: .env | ||
- 8080:8080 | ||
tty: true | ||
environment: | ||
MYSQL_ROOT_PASSWORD: mysql | ||
DATABASE_NAME: mysql | ||
DATABASE_USER: 'root' | ||
DATABASE_PASSWORD: mysql | ||
DATABASE_PORT: 3306 | ||
DATABASE_HOST: db | ||
# restart: always | ||
volumes: | ||
- .:/app | ||
- TZ=Asia/Seoul | ||
|
||
volumes: | ||
app: | ||
dbdata: | ||
nginx: | ||
container_name: nginx | ||
image: yeniwithchoi/ceos-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 nginx | ||
RUN rm -rf /etc/nginx/conf.d/default.conf | ||
COPY ./nginx/conf.d/nginx.conf /etc/nginx/conf.d | ||
CMD ["nginx", "-g", "daemon off;"] |
Oops, something went wrong.