Skip to content

Commit

Permalink
Update cite domain name
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Svidunovich authored and Kirill Svidunovich committed Nov 11, 2023
1 parent 7dfe8e1 commit bd4e3f4
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 67 deletions.
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@

# Secrets
ACCESS_TOKEN_LIFETIME=1
SECRET_KEY='django-insecure-<top-secret-symbols>'

# Domain
CITE_DOMAIN=hr-praktikum.domain.com
CITE_DOMAIN=hr-practicum.domain.com
CITE_IP=11.111.111.111

# Frontend Vite
VITE_API_URL=hr-praktikum.domain.com/api/v1
VITE_API_URL=hr-practicum.domain.com/api/v1

# Database settings
DB_ENGINE=django.db.backends.postgresql
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ jobs:
with:
context: ./hakaton/
push: True
tags: ${{ secrets.DOCKERHUB_USERNAME }}/hr_praktikum_backend:latest
tags: ${{ secrets.DOCKERHUB_USERNAME }}/hr_practicum_backend:latest
- name: Push gateway image to the Dockerhub
uses: docker/build-push-action@v4
with:
context: ./gateway/
push: True
tags: ${{ secrets.DOCKERHUB_USERNAME }}/hr_praktikum_gateway:latest
tags: ${{ secrets.DOCKERHUB_USERNAME }}/hr_practicum_gateway:latest

deploy_on_server:
name: Deploy project on server
Expand All @@ -86,21 +86,21 @@ jobs:
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
source: "docker-compose.production.yml"
target: "/home/hr_praktikum/"
target: "/home/hr_practicum/"
- name: Executing remote ssh commands to deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /home/hr_praktikum
cd /home/hr_practicum
sudo docker compose down
sudo rm docker-compose.yml
sudo mv docker-compose.production.yml docker-compose.yml
sudo docker image rm ${{ secrets.DOCKERHUB_USERNAME }}/hr_praktikum_backend
sudo docker image rm ${{ secrets.DOCKERHUB_USERNAME }}/hr_praktikum_gateway
sudo docker volume rm hr_praktikum_hr_praktikum_static_volume
sudo docker image rm ${{ secrets.DOCKERHUB_USERNAME }}/hr_practicum_backend
sudo docker image rm ${{ secrets.DOCKERHUB_USERNAME }}/hr_practicum_gateway
sudo docker volume rm hr_practicum_hr_practicum_static_volume
sudo docker compose up -d --build
sudo service nginx restart
Expand All @@ -114,4 +114,4 @@ jobs:
with:
to: ${{ secrets.TELEGRAM_ME_ID }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
message: Деплой "Hr-Praktikum backend" выполнен успешно!
message: Деплой "Hr-practicum backend" выполнен успешно!
44 changes: 22 additions & 22 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
version: '3.8'

volumes:
hr_praktikum_database_volume:
hr_praktikum_static_volume:
hr_praktikum_media_volume:
hr_practicum_database_volume:
hr_practicum_static_volume:
hr_practicum_media_volume:

services:

hr_praktikum_database:
hr_practicum_database:
image: postgres:15-alpine
volumes:
- hr_praktikum_database_volume:/var/lib/postgresql/data/
- hr_practicum_database_volume:/var/lib/postgresql/data/
env_file:
- .env

hr_praktikum_redis:
hr_practicum_redis:
image: redis:7.2.1-alpine

hr_praktikum_backend:
image: thesuncatcher222/hr_praktikum_backend:latest
hr_practicum_backend:
image: thesuncatcher222/hr_practicum_backend:latest
env_file: .env
volumes:
- hr_praktikum_static_volume:/app/static
- hr_praktikum_media_volume:/app/media
- hr_practicum_static_volume:/app/static
- hr_practicum_media_volume:/app/media
depends_on:
- hr_praktikum_database
- hr_praktikum_redis
- hr_practicum_database
- hr_practicum_redis

hr_praktikum_frontend:
image: thesuncatcher222/hr_praktikum_frontend:latest
hr_practicum_frontend:
image: thesuncatcher222/hr_practicum_frontend:latest
volumes:
- hr_praktikum_static_volume:/app/build
- hr_practicum_static_volume:/app/build
env_file: .env
depends_on:
- hr_praktikum_backend
- hr_practicum_backend

hr_praktikum_gateway:
image: thesuncatcher222/hr_praktikum_gateway:latest
hr_practicum_gateway:
image: thesuncatcher222/hr_practicum_gateway:latest
ports:
- "8000:8000"
volumes:
- hr_praktikum_static_volume:/var/html/static/
- hr_praktikum_media_volume:/var/html/media/
- hr_practicum_static_volume:/var/html/static/
- hr_practicum_media_volume:/var/html/media/
depends_on:
- hr_praktikum_backend
- hr_praktikum_frontend
- hr_practicum_backend
- hr_practicum_frontend
38 changes: 19 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
version: '3.8'

volumes:
hr_praktikum_database_volume:
hr_praktikum_static_volume:
hr_praktikum_media_volume:
hr_practicum_database_volume:
hr_practicum_static_volume:
hr_practicum_media_volume:

services:

hr_praktikum_database:
hr_practicum_database:
image: postgres:15-alpine
volumes:
- hr_praktikum_database_volume:/var/lib/postgresql/data/
- hr_practicum_database_volume:/var/lib/postgresql/data/
env_file:
- .env

hr_praktikum_redis:
hr_practicum_redis:
image: redis:7.2.1-alpine

hr_praktikum_backend:
hr_practicum_backend:
build: ./hakaton/
env_file: .env
volumes:
- hr_praktikum_static_volume:/app/static
- hr_praktikum_media_volume:/app/media
- hr_practicum_static_volume:/app/static
- hr_practicum_media_volume:/app/media
depends_on:
- hr_praktikum_database
- hr_praktikum_redis
- hr_practicum_database
- hr_practicum_redis

hr_praktikum_frontend:
hr_practicum_frontend:
build: ../frontend/
volumes:
- hr_praktikum_static_volume:/app/build
- hr_practicum_static_volume:/app/build
env_file: .env
depends_on:
- hr_praktikum_backend
- hr_practicum_backend

hr_praktikum_gateway:
hr_practicum_gateway:
build: ./gateway/
ports:
- "8000:8000"
volumes:
- hr_praktikum_static_volume:/var/html/static/
- hr_praktikum_media_volume:/var/html/media/
- hr_practicum_static_volume:/var/html/static/
- hr_practicum_media_volume:/var/html/media/
depends_on:
- hr_praktikum_backend
- hr_praktikum_frontend
- hr_practicum_backend
- hr_practicum_frontend
4 changes: 2 additions & 2 deletions gateway/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ server {

location /admin/ {
proxy_set_header Host $http_host;
proxy_pass http://hr_praktikum_backend:8000/admin/;
proxy_pass http://hr_practicum_backend:8000/admin/;
}

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

location /media/ {
Expand Down
2 changes: 1 addition & 1 deletion hakaton/hakaton/app_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def user_avatar_path(instance, filename) -> str:
"""Email settings."""


DEFAULT_FROM_EMAIL = 'Praktikum Services'
DEFAULT_FROM_EMAIL = 'practicum Services'

EMAIL_HOST: str = os.getenv('EMAIL_HOST')
EMAIL_PORT: int = int(os.getenv('EMAIL_PORT'))
Expand Down
4 changes: 2 additions & 2 deletions hakaton/hakaton/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
CELERY_TASK_TRACK_STARTED = True
CELERY_TASK_TIME_LIMIT = 30 * 60

CELERY_BROKER_URL = 'redis://hr_praktikum_redis:6379/0'
CELERY_RESULT_BACKEND = 'redis://hr_praktikum_redis:6379/0'
CELERY_BROKER_URL = 'redis://hr_practicum_redis:6379/0'
CELERY_RESULT_BACKEND = 'redis://hr_practicum_redis:6379/0'


"""Email settings."""
Expand Down
2 changes: 1 addition & 1 deletion hakaton/run_django_not_prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
echo @@@@@@@@@@@@@@@@@@@@@@@ waiting for database @@@@@@@@@@@@@@@@@@@@@@@@
echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

while ! pg_isready -h hr_praktikum_database -p 5432; do
while ! pg_isready -h hr_practicum_database -p 5432; do
echo "База данных недоступна, ждем 5 секунд..."
sleep 5
done
Expand Down
10 changes: 0 additions & 10 deletions hakaton/user/management/commands/csv_db_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,6 @@ def import_vacancy_student_status() -> None:
return


def create_admin():
"""Создает модель суперпользователя."""
email: str = '[email protected]'
password: str = 'admin'
if not User.objects.filter(email=email):
User.objects.create_superuser(email=email, password=password)
return


def create_student():
"""Создает объекты разных студентов."""
csv_data: csv.DictReader = import_csv(csv_name='student')
Expand Down Expand Up @@ -370,7 +361,6 @@ def handle(self, *args: any, **options: any):
import_skill_category()
import_skill()
import_vacancy_student_status()
create_admin()
create_student()
create_vacancy()
except Exception as err:
Expand Down

0 comments on commit bd4e3f4

Please sign in to comment.