diff --git a/.github/workflows/liara.yaml b/.github/workflows/liara.yaml new file mode 100644 index 0000000..7c929b1 --- /dev/null +++ b/.github/workflows/liara.yaml @@ -0,0 +1,21 @@ +name: CD-Liara +on: + push: + branches: + - main + - dev +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: "18" + - name: update-liara + env: + LIARA_TOKEN: ${{ secrets.LIARA_API_TOKEN }} + run: | + npm i -g @liara/cli@5 + liara deploy --app="gizmoshop" --api-token="$LIARA_TOKEN" --no-app-logs \ No newline at end of file diff --git a/config/settings.py b/config/settings.py index a3b1ed2..8a87906 100644 --- a/config/settings.py +++ b/config/settings.py @@ -5,10 +5,18 @@ BASE_DIR = Path(__file__).resolve().parent.parent +deploy = True +if(deploy): + # deploy + SECRET_KEY = os.getenv('SECRET_KEY', 'LIARA_URL is not set.') + DEBUG = os.getenv('DEBUG', 'LIARA_URL is not set.') + +else: + SECRET_KEY = "dkfgjiuerhguehrgedjgnerfghiuer" + DEBUG = True + -SECRET_KEY = "dkfgjiuerhguehrgedjgnerfghiuer" -DEBUG = True ALLOWED_HOSTS = ["*","89.199.35.132","192.168.45.68",] CORS_ORIGIN_ALLOW_ALL = True @@ -96,7 +104,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', + 'NAME': BASE_DIR / 'media/db.sqlite3', } } diff --git a/liara.json b/liara.json new file mode 100644 index 0000000..bcd0214 --- /dev/null +++ b/liara.json @@ -0,0 +1,8 @@ +{ + "disks": [ + { + "name": "data", + "mountTo": "media" + } + ] +} \ No newline at end of file diff --git a/liara_nginx.conf b/liara_nginx.conf new file mode 100644 index 0000000..4868aa7 --- /dev/null +++ b/liara_nginx.conf @@ -0,0 +1,33 @@ +client_max_body_size 100M; + +location /media { + add_header Access-Control-Allow-Origin *; + alias /usr/src/app/media; + + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain; charset=utf-8'; + add_header 'Content-Length' 0; + return 204; + } +} + +location /static { + alias /usr/src/app/staticfiles; +} + +location / { + try_files /dev/null @django_app; +} + +location ~\.sqlite3$ { + deny all; + error_page 403 =404 /; +} + +location ~ /\.well-known { + allow all; +} \ No newline at end of file