I dunno how to pro gram

This commit is contained in:
Michał Gdula 2023-06-18 21:50:07 +00:00
parent a71584ef98
commit 7617e19e66
47 changed files with 70 additions and 25 deletions

View file

@ -2,12 +2,17 @@
FROM alpine:latest
EXPOSE 8000
WORKDIR /website
RUN apk update && apk add build-base postgresql-client \
python3 py3-pip python3-dev --no-cache
RUN mkdir /app
WORKDIR /app
COPY requirements.txt requirements.txt
COPY ./website ./website
RUN apk update && apk add python3 py3-pip
RUN pip install -r requirements.txt
CMD ["python3", "manage.py", "runserver", ""]
COPY website .
COPY run.sh run.sh
RUN chmod +x run.sh
CMD ["./run.sh"]

8
website/requirements.txt Normal file
View file

@ -0,0 +1,8 @@
Gunicorn
django
psycopg2-binary
tzdata
pillow
django-libsass
django-compressor
django-markdownify

24
website/run.sh Normal file
View file

@ -0,0 +1,24 @@
#!/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)"
sleep 5
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..."
python3 manage.py makemigrations
python3 manage.py migrate
fi
# Start server!!!!
echo "Starting server..."
gunicorn --bind :8000 website.wsgi:application

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View file

Before

Width:  |  Height:  |  Size: 256 KiB

After

Width:  |  Height:  |  Size: 256 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 602 KiB

After

Width:  |  Height:  |  Size: 602 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 184 KiB

After

Width:  |  Height:  |  Size: 184 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Before After
Before After

View file

@ -78,20 +78,13 @@ WSGI_APPLICATION = "website.wsgi.application"
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
# DATABASES = {
# "default": {
# "ENGINE": "django.db.backends.sqlite3",
# "NAME": BASE_DIR / "db.sqlite3",
# }
# }
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'ENGINE': "django.db.backends.postgresql",
'NAME': getenv('POSTGRES_DB'),
'USER': getenv('POSTGRES_USER'),
'PASSWORD': getenv('POSTGRES_PASSWORD'),
'HOST': getenv('POSTGRES_HOST'),
'HOST': 'db',
'PORT': 5432,
}
}