Fix SQLite permission issue (#1984)
# What this PR does Fixes https://github.com/grafana/oncall/issues/1960. ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
This commit is contained in:
parent
663987c57e
commit
53d34164ef
5 changed files with 31 additions and 5 deletions
|
|
@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- Allow passing Firebase credentials via environment variable by @vadimkerr ([#1969](https://github.com/grafana/oncall/pull/1969))
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix SQLite permission issue by @vadimkerr ([#1984](https://github.com/grafana/oncall/pull/1984))
|
||||
|
||||
## v1.2.26 (2023-05-18)
|
||||
|
||||
### Fixed
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@ RUN pip install -r requirements.txt
|
|||
# https://stackoverflow.com/questions/34398632/docker-how-to-run-pip-requirements-txt-only-if-there-was-a-change/34399661#34399661
|
||||
COPY ./ ./
|
||||
|
||||
# Collect static files and create an SQLite database
|
||||
RUN mkdir -p /var/lib/oncall
|
||||
# Collect static files
|
||||
RUN DJANGO_SETTINGS_MODULE=settings.prod_without_db DATABASE_TYPE=sqlite3 DATABASE_NAME=/var/lib/oncall/oncall.db SECRET_KEY="ThEmUsTSecretKEYforBUILDstage123" SILK_PROFILER_ENABLED="True" python manage.py collectstatic --no-input
|
||||
|
||||
# Create SQLite database and set permissions
|
||||
RUN mkdir -p /var/lib/oncall
|
||||
RUN DATABASE_TYPE=sqlite3 DATABASE_NAME=/var/lib/oncall/oncall.db python manage.py create_sqlite_db
|
||||
RUN chown -R 1000:2000 /var/lib/oncall
|
||||
|
||||
# This is required for silk profilers to sync between uwsgi workers
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from apps.telegram.tasks import register_telegram_webhook
|
||||
from apps.telegram.updates.update_manager import UpdateManager
|
||||
|
||||
register_telegram_webhook.delay()
|
||||
|
||||
|
||||
class WebHookView(APIView):
|
||||
def get(self, request, format=None):
|
||||
|
|
|
|||
|
|
@ -53,6 +53,13 @@ def on_after_setup_logger(logger, **kwargs):
|
|||
)
|
||||
|
||||
|
||||
@celery.signals.worker_ready.connect
|
||||
def on_worker_ready(*args, **kwargs):
|
||||
from apps.telegram.tasks import register_telegram_webhook
|
||||
|
||||
register_telegram_webhook.delay()
|
||||
|
||||
|
||||
if settings.OTEL_TRACING_ENABLED and settings.OTEL_EXPORTER_OTLP_ENDPOINT:
|
||||
|
||||
@celery.signals.worker_process_init.connect(weak=False)
|
||||
|
|
|
|||
15
engine/engine/management/commands/create_sqlite_db.py
Normal file
15
engine/engine/management/commands/create_sqlite_db.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import connection
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
Create SQLite3 database file if it doesn't exist.
|
||||
"""
|
||||
|
||||
def handle(self, *args, **options):
|
||||
assert settings.DATABASE_TYPE == "sqlite3"
|
||||
|
||||
# Creating a cursor creates the database file if it doesn't exist.
|
||||
connection.cursor()
|
||||
Loading…
Add table
Reference in a new issue