Update: docker.yml #8
Workflow file for this run
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
name: Issue 18 Workflow | |
on: | |
push: | |
branches: | |
- issue/18 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
- name: Run chmod to make gradlew executable | |
run: chmod +x ./gradlew | |
- name: Install Docker Compose | |
run: | | |
# Docker Compose 설치 스크립트 | |
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o ./docker-compose | |
chmod +x ./docker-compose | |
sudo mv ./docker-compose /usr/local/bin/docker-compose | |
- name: Build with Gradle | |
run: ./gradlew clean build --exclude-task test | |
## 웹 이미지 빌드 및 도커허브에 push | |
- name: web docker build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_REPO }}/mappin-server . | |
docker push ${{ secrets.DOCKER_REPO }}/mappin-server | |
## docker compose up | |
- name: Install Docker and Docker Compose on EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.KEY }} | |
script: | | |
# Docker 설치 | |
sudo apt-get update | |
sudo apt-get -y install docker.io | |
sudo systemctl start docker | |
sudo systemctl enable docker | |
# Docker Compose 설치 | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
# 기존 컨테이너 제거 | |
sudo docker rm -f $(sudo docker ps -qa) | |
# Docker 이미지 다운로드 | |
sudo docker pull ${{ secrets.DOCKER_REPO }}/mappin-server | |
sudo docker pull ${{ secrets.DOCKER_REPO }}/mappin-nginx | |
# Docker Compose 실행 | |
sudo docker-compose up -d | |
# 사용하지 않는 Docker 이미지 정리 | |
sudo docker image prune -f |