Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add swag #36

Merged
merged 25 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/deploy_stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
host: ${{ secrets.HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
source: "infra/docker-compose.staging.yml,infra/nginx/nginx.local.conf"
source: "infra/docker-compose.swag.yml, infra/swag_nginx.conf"
target: ${{ env.DEPLOY_PATH }}

- name: Create .env file
Expand All @@ -82,7 +82,7 @@ jobs:
password: ${{ secrets.SSH_PASSWORD }}
script: |
cd ${{ env.DEPLOY_PATH }}
mv infra/docker-compose.staging.yml infra/docker-compose.yaml
mv infra/docker-compose.swag.yml infra/docker-compose.yaml
rm -f .env
cat > .env <<- EOM
POSTGRES_DB=${{ secrets.POSTGRES_DB }}
Expand Down Expand Up @@ -111,6 +111,7 @@ jobs:
password: ${{ secrets.SSH_PASSWORD }}
script: |
cd ${{ env.DEPLOY_PATH }}/infra
docker ps
docker image prune -f
docker pull ${{ env.REGISTRY }}/${{ env.REP_OWNER }}/${{ env.IMAGE_NAME }}:latest
docker compose --file docker-compose.yaml stop
Expand Down
62 changes: 62 additions & 0 deletions infra/docker-compose.swag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
version: "3.8"



services:
backend:
image: ghcr.io/studio-yandex-practicum/procharity_back_2.0_backend:latest
container_name: procharity_bot_backend
restart: always
depends_on:
postgres:
condition: service_healthy
ports:
- "8000:8000"
env_file:
- ../.env

postgres:
image: postgres:13.2
container_name: procharity_postgres
restart: always
ports:
- "9999:5432"
Aleksey-shipkov marked this conversation as resolved.
Show resolved Hide resolved
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- ../.env
healthcheck:
test: [ "CMD-SHELL", "pg_isready" ]
Aleksey-shipkov marked this conversation as resolved.
Show resolved Hide resolved
interval: 10s
timeout: 5s
retries: 5

swag:
image: lscr.io/linuxserver/swag:2.4.0
container_name: procharity_swag
cap_add:
- NET_ADMIN
environment:
- TZ=Europe/Moscow
- URL=procharity.duckdns.com
Aleksey-shipkov marked this conversation as resolved.
Show resolved Hide resolved
- VALIDATION=http
- CERTPROVIDER=zerossl
- [email protected]
env_file:
- ../.env
volumes:
- /procharity2/full/nginx_logs:/var/log/nginx
Aleksey-shipkov marked this conversation as resolved.
Show resolved Hide resolved
- ./swag_nginx.conf:/config/nginx/site-confs/default.conf
- keys:/config/keys
ports:
- "443:443"
- "80:80"
restart: unless-stopped
depends_on:
- backend

volumes:
postgres_data:
keys:


29 changes: 29 additions & 0 deletions infra/swag_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
server {
listen 80;
listen [::]:80;
server_name _;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
listen [::]:443 ssl;

server_name procharity.duckdns.com;
NiKuma0 marked this conversation as resolved.
Show resolved Hide resolved

include /config/nginx/ssl.conf;

root /var/www/;

client_max_body_size 25M;

server_tokens off;

location /api/ {
proxy_pass http://backend:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}