-
Notifications
You must be signed in to change notification settings - Fork 20
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 #4 from ashenBlade/deploy
Deploy
- Loading branch information
Showing
29 changed files
with
319 additions
and
652 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,87 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
pull: | ||
branches: [ "main" ] | ||
|
||
env: | ||
FRONTEND_IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/text-to-image-frontend:${{ github.sha }} | ||
BACKEND_IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/text-to-image-api:${{ github.sha }} | ||
NGINX_IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/text-to-image-nginx:${{ github.sha }} | ||
|
||
jobs: | ||
build-docker: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to Dockerhub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build Backend | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: src/backend | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ env.BACKEND_IMAGE }} | ||
|
||
- name: Build Frontend | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: src/backend | ||
file: ./Dockerfile | ||
push: true | ||
build-args: | | ||
server_url: ${{ secrets.API_SERVER_URL }} | ||
tags: ${{ env.FRONTEND_IMAGE }} | ||
|
||
- name: Compose together with Nginx | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: nginx | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ env.NGINX_IMAGE }} | ||
|
||
|
||
update-yc: | ||
runs-on: ubuntu-latest | ||
needs: [build-docker] | ||
steps: | ||
|
||
- name: Login to Yandex Cloud | ||
id: logic-cr | ||
uses: yc-actions/yc-cr-login@v1 | ||
with: | ||
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }} | ||
|
||
|
||
- name: Deploy COI VM | ||
id: deploy-coi | ||
uses: yc-actions/yc-coi-deploy@v1 | ||
env: | ||
BACKEND_IMAGE: $BACKEND_IMAGE | ||
FRONTEND_IMAGE: $FRONTEND_IMAGE | ||
NGINX_IMAGE: $NGINX_IMAGE | ||
FRONTEND_ORIGINS: ${{ secrets.FRONTEND_ORIGINS }} | ||
YC_VM_SSH: ${{ secrets.YC_VM_SSH }} | ||
with: | ||
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }} | ||
folder-id: ${{ secrets.YC_FOLDER_ID }} | ||
VM-name: ${{ secrets.YC_VM_NAME }} | ||
vm-service-account-id: ${{ secrets.YC_SERVICE_ACCOUNT_ID }} | ||
vm-cores: 1 | ||
vm-memory: 1Gb | ||
vm-core-fraction: 20 | ||
vm-subnet-id: ${{ secrets.YC_SUBNET_ID }} | ||
docker-compose-path: './yandex-cloud/docker-compose.yc.yml' | ||
user-data-path: './yandex-cloud/user-data.yml' |
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 |
---|---|---|
|
@@ -130,3 +130,5 @@ dmypy.json | |
|
||
# PyCharm folders | ||
.idea | ||
|
||
*.local.* |
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,5 @@ | ||
FROM nginx:alpine | ||
|
||
COPY ./nginx.yc.conf /etc/nginx/conf.d/default.conf | ||
EXPOSE 80 | ||
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,11 @@ | ||
server { | ||
listen 80; | ||
|
||
location /api { | ||
proxy_pass http://backend; | ||
} | ||
|
||
location / { | ||
proxy_pass http://frontend; | ||
} | ||
} |
Oops, something went wrong.