forked from CEOS-Developers/spring-everytime-19th
-
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
1 parent
5a61d6a
commit 1a07147
Showing
5 changed files
with
111 additions
and
4 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,65 @@ | ||
name: Deploy Development Server | ||
|
||
## develop 브랜치에 push가 되면 실행됩니다 | ||
on: | ||
push: | ||
branches: [ "nimikgnoej" ] | ||
|
||
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: 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 my-repo/my-web-image . | ||
docker push my-repo/my-web-image | ||
docker build -f dockerfile-nginx -t my-repo/my-nginx-image . | ||
docker push my-repo/my-nginx-image | ||
- 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.yaml 파일을 생성합니다. | ||
sudo touch docker-compose.yaml | ||
echo "${{ vars.DOCKER_COMPOSE }}" | sudo tee docker-compose.yaml > /dev/null | ||
## docker-compose를 실행합니다. | ||
sudo chmod 666 /var/run/docker.sock | ||
sudo docker rm -f $(docker ps -qa) | ||
sudo docker pull my-repo/my-web-image | ||
sudo docker pull my-repo/my-nginx-image | ||
docker-compose -f docker-compose.yaml --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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: '3' | ||
services: | ||
|
||
web: | ||
container_name: web | ||
image: my-repo/my-web-image | ||
env_file: | ||
- .env | ||
expose: | ||
- 8080 | ||
ports: | ||
- 8080:8080 | ||
tty: true | ||
environment: | ||
- TZ=Asia/Seoul | ||
|
||
nginx: | ||
container_name: nginx | ||
image: my-repo/my-nignx-image | ||
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;"] |
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; | ||
} | ||
} |
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