diff --git a/docker-compose.yml b/docker-compose.yml index a7651d9..7c77fb5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,18 +5,28 @@ services: image: postgres:alpine restart: unless-stopped volumes: - - ./postgres/data:/var/lib/postgresql/data + - ./data/postgres:/var/lib/postgresql/data environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} + # proxy: + # image: caddy:alpine + # restart: unless-stopped + # ports: + # - "80:80" + # volumes: + # - ./data/caddy/Caddyfile:/etc/caddy/Caddyfile + # - ./data/static:/website/static + # - ./data/media:/website/media website: build: website restart: unless-stopped volumes: - - ./data/media:/website/media + - ./data/static:/app/static + - ./data/media:/app/media environment: DJANGO_KEY: ${DJANGO_KEY} POSTGRES_USER: ${POSTGRES_USER} @@ -25,4 +35,5 @@ services: depends_on: - db ports: - - "6212:8000" + - "8000:8000" + diff --git a/website/Dockerfile b/website/Dockerfile index dedf951..c764736 100644 --- a/website/Dockerfile +++ b/website/Dockerfile @@ -11,7 +11,7 @@ WORKDIR /app COPY requirements.txt requirements.txt RUN pip install -r requirements.txt -COPY website . +COPY ./website/ /app/ COPY run.sh run.sh RUN chmod +x run.sh diff --git a/website/run.sh b/website/run.sh index a03d5a4..3c82be5 100644 --- a/website/run.sh +++ b/website/run.sh @@ -1,6 +1,5 @@ #!/bin/sh -# Wait for database to start until pg_isready -d $POSTGRES_DB -h db -U $POSTGRES_USER do echo "Waiting for database to start... (5s)" @@ -9,8 +8,6 @@ done echo "Database is ready!" -# Check if there are any changes to the database -#python3 manage.py showmigrations if (python3 manage.py showmigrations | grep "\[ \]" > /dev/null); then echo "Database changes detected! Migrating..." @@ -18,7 +15,9 @@ then python3 manage.py migrate fi -# Start server!!!! +# echo "Collecting static files..." +# python3 manage.py collectstatic --noinput + echo "Starting server..." gunicorn --bind :8000 website.wsgi:application diff --git a/website/website/website/settings.py b/website/website/website/settings.py index 06ee609..fa70f9a 100644 --- a/website/website/website/settings.py +++ b/website/website/website/settings.py @@ -29,6 +29,10 @@ DEBUG = True ALLOWED_HOSTS = ["*"] +CSRF_TRUSTED_ORIGINS = [ + 'https://*.leggy.dev', +] + # Application definition @@ -124,7 +128,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ -STATIC_URL = "static/" +STATIC_URL = "static" STATICFILES_DIRS = (join(BASE_DIR, "static"),) STATICFILES_FINDERS = [ "compressor.finders.CompressorFinder", @@ -132,7 +136,7 @@ STATICFILES_FINDERS = [ "django.contrib.staticfiles.finders.AppDirectoriesFinder", ] -MEDIA_URL = "media/" +MEDIA_URL = "media" MEDIA_ROOT = join(BASE_DIR, "media") COMPRESS_ROOT = join(BASE_DIR, "static/")