-
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 #51 from aeyongdodam/aeyongdodam
[18기_이소현] Github Action을 이용한 CI/CD 배포 미션 제출합니다.
- Loading branch information
Showing
5 changed files
with
199 additions
and
3 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,58 @@ | ||
name: Deploy Development Server | ||
on: | ||
push: | ||
branches: ["aeyongdodam"] | ||
|
||
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" | ||
- name: Create resources directory | ||
run: mkdir -p ./clone-coding/src/main/resources | ||
- name: Prepare application.yml | ||
run: | | ||
echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml | ||
working-directory: ./clone-coding | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew bootJar | ||
working-directory: ./clone-coding | ||
|
||
- name: web docker build and push | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -t aeyongdodam/my-web-image . | ||
docker push aeyongdodam/my-web-image | ||
docker build -f dockerfile-nginx -t aeyongdodam/my-nginx-image . | ||
docker push aeyongdodam/my-nginx-image | ||
working-directory: ./clone-coding | ||
|
||
- 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/ | ||
sudo touch docker-compose.yaml | ||
echo "${{ secrets.DOCKER_COMPOSE }}" | sudo tee docker-compose.yaml > /dev/null | ||
sudo chmod 666 /var/run/docker.sock | ||
sudo docker rm -f $(docker ps -qa) | ||
sudo docker pull aeyongdodam/my-web-image | ||
sudo docker pull aeyongdodam/my-nginx-image | ||
docker-compose -f docker-compose.yaml | ||
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
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;"] |
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,15 @@ | ||
server { | ||
listen 80; | ||
server_name *.compute.amazonaws.com; | ||
|
||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
|
||
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; | ||
} | ||
} |