This commit is contained in:
Michał 2023-06-19 12:12:22 +00:00
parent 7617e19e66
commit 4394e713bd
4 changed files with 24 additions and 10 deletions

View file

@ -5,18 +5,28 @@ services:
image: postgres:alpine image: postgres:alpine
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ./postgres/data:/var/lib/postgresql/data - ./data/postgres:/var/lib/postgresql/data
environment: environment:
POSTGRES_USER: ${POSTGRES_USER} POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB} 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: website:
build: website build: website
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ./data/media:/website/media - ./data/static:/app/static
- ./data/media:/app/media
environment: environment:
DJANGO_KEY: ${DJANGO_KEY} DJANGO_KEY: ${DJANGO_KEY}
POSTGRES_USER: ${POSTGRES_USER} POSTGRES_USER: ${POSTGRES_USER}
@ -25,4 +35,5 @@ services:
depends_on: depends_on:
- db - db
ports: ports:
- "6212:8000" - "8000:8000"

View file

@ -11,7 +11,7 @@ WORKDIR /app
COPY requirements.txt requirements.txt COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt RUN pip install -r requirements.txt
COPY website . COPY ./website/ /app/
COPY run.sh run.sh COPY run.sh run.sh
RUN chmod +x run.sh RUN chmod +x run.sh

View file

@ -1,6 +1,5 @@
#!/bin/sh #!/bin/sh
# Wait for database to start
until pg_isready -d $POSTGRES_DB -h db -U $POSTGRES_USER until pg_isready -d $POSTGRES_DB -h db -U $POSTGRES_USER
do do
echo "Waiting for database to start... (5s)" echo "Waiting for database to start... (5s)"
@ -9,8 +8,6 @@ done
echo "Database is ready!" 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); if (python3 manage.py showmigrations | grep "\[ \]" > /dev/null);
then then
echo "Database changes detected! Migrating..." echo "Database changes detected! Migrating..."
@ -18,7 +15,9 @@ then
python3 manage.py migrate python3 manage.py migrate
fi fi
# Start server!!!! # echo "Collecting static files..."
# python3 manage.py collectstatic --noinput
echo "Starting server..." echo "Starting server..."
gunicorn --bind :8000 website.wsgi:application gunicorn --bind :8000 website.wsgi:application

View file

@ -29,6 +29,10 @@ DEBUG = True
ALLOWED_HOSTS = ["*"] ALLOWED_HOSTS = ["*"]
CSRF_TRUSTED_ORIGINS = [
'https://*.leggy.dev',
]
# Application definition # Application definition
@ -124,7 +128,7 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/ # https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_URL = "static/" STATIC_URL = "static"
STATICFILES_DIRS = (join(BASE_DIR, "static"),) STATICFILES_DIRS = (join(BASE_DIR, "static"),)
STATICFILES_FINDERS = [ STATICFILES_FINDERS = [
"compressor.finders.CompressorFinder", "compressor.finders.CompressorFinder",
@ -132,7 +136,7 @@ STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.AppDirectoriesFinder", "django.contrib.staticfiles.finders.AppDirectoriesFinder",
] ]
MEDIA_URL = "media/" MEDIA_URL = "media"
MEDIA_ROOT = join(BASE_DIR, "media") MEDIA_ROOT = join(BASE_DIR, "media")
COMPRESS_ROOT = join(BASE_DIR, "static/") COMPRESS_ROOT = join(BASE_DIR, "static/")