Skip to content

Commit

Permalink
Merge pull request #137 from Pet-projects-CodePET/feature/ssl
Browse files Browse the repository at this point in the history
Feature/ssl
  • Loading branch information
VladislavCR authored Mar 22, 2024
2 parents d4bdb6f + 183d6a4 commit 2f4d5e7
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
with:
context: ./infra/nginx/
push: true
build-args: NGINX_NAME=${{ secrets.NGINX_DEV }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}_nginx:latest

build_and_push_to_docker_hub_certbot:
Expand All @@ -63,6 +64,7 @@ jobs:
with:
context: ./infra/certbot/
push: true
build-args: DOMAIN_NAME=${{ secrets.DOMAIN_DEV }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}_certbot:latest

deploy:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/qa_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Push to DockerHub
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: ./
push: true
Expand All @@ -39,7 +39,7 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Push to DockerHub
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: ./infra/nginx/
push: true
Expand Down Expand Up @@ -129,6 +129,6 @@ jobs:
sudo docker compose -f docker-compose-prod.yaml exec backend python manage.py migrate
sudo docker compose -f docker-compose-prod.yaml exec backend python manage.py collectstatic --no-input
sudo docker compose -f docker-compose-prod.yaml exec backend cp -r static/. /backend_static/static/
sudo docker compose -f docker-compose-prod.yaml run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d devcodepet.tw1.ru
sudo docker compose -f docker-compose-prod.yaml run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d testcodepet.tw1.ru
sudo docker compose -f docker-compose-prod.yaml run --rm certbot renew
sudo docker system prune -f
4 changes: 2 additions & 2 deletions infra/certbot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ FROM certbot/certbot

ARG DOMAIN_NAME

COPY fullchain.pem /letsencrypt/live/${DOMAIN_NAME}/fullchain.pem
COPY fullchain.pem letsencrypt/live/${DOMAIN_NAME}/fullchain.pem

COPY privkey.pem /letsencrypt/live/${DOMAIN_NAME}/privkey.pem
COPY privkey.pem letsencrypt/live/${DOMAIN_NAME}/privkey.pem
2 changes: 1 addition & 1 deletion infra/nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM nginx:1.25.4-alpine-slim

ARG NGINX_NAME

COPY nginx_dev.conf /etc/nginx/templates/default.conf.template
COPY ${NGINX_NAME} /etc/nginx/templates/default.conf.template
56 changes: 28 additions & 28 deletions infra/nginx/nginx_qa.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ server {
}
}

server {
listen 443 default_server ssl http2;
listen [::]:443 ssl http2;
server_name 89.23.117.168 testcodepet.tw1.ru;

ssl_certificate /etc/nginx/ssl/live/testcodepet.tw1.ru/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/testcodepet.tw1.ru/privkey.pem;

root /staticfiles;

location /api/v1/ {
proxy_set_header Host $http_host;
proxy_pass http://backend:8000/api/v1/;
}
location /admin/ {
proxy_set_header Host $http_host;
proxy_pass http://backend:8000/admin/;
}

location / {
try_files $uri $uri.html $uri/ =404;
}

error_page 404 /404.html;
location = /404.html {
internal;
}
}
# server {
# listen 443 default_server ssl http2;
# listen [::]:443 ssl http2;
# server_name 89.23.117.168 testcodepet.tw1.ru;

# ssl_certificate /letsencrypt/live/testcodepet.tw1.ru/fullchain.pem;
# ssl_certificate_key /letsencrypt/live/testcodepet.tw1.ru/privkey.pem;

# root /staticfiles;

# location /api/v1/ {
# proxy_set_header Host $http_host;
# proxy_pass http://backend:8000/api/v1/;
# }
# location /admin/ {
# proxy_set_header Host $http_host;
# proxy_pass http://backend:8000/admin/;
# }

# location / {
# try_files $uri $uri.html $uri/ =404;
# }

# error_page 404 /404.html;
# location = /404.html {
# internal;
# }
# }
2 changes: 1 addition & 1 deletion src/backend/config/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
CORS_ALLOWED_ORIGINS = [
"https://89.23.117.80",
"https://devcodepet.tw1.ru",
"https://localhost:3000",
"http://localhost:3000",
]
2 changes: 1 addition & 1 deletion src/backend/config/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
CORS_ALLOWED_ORIGINS = [
"https://89.23.117.168",
"https://testcodepet.tw1.ru",
"https://localhost:3000",
"http://localhost:3000",
]

0 comments on commit 2f4d5e7

Please sign in to comment.