I dunno how to pro gram
|
@ -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
|
@ -0,0 +1,8 @@
|
|||
Gunicorn
|
||||
django
|
||||
psycopg2-binary
|
||||
tzdata
|
||||
pillow
|
||||
django-libsass
|
||||
django-compressor
|
||||
django-markdownify
|
24
website/run.sh
Normal 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
|
||||
|
BIN
website/website/media/default.jpg
Normal file
After Width: | Height: | Size: 134 KiB |
Before Width: | Height: | Size: 256 KiB After Width: | Height: | Size: 256 KiB |
Before Width: | Height: | Size: 602 KiB After Width: | Height: | Size: 602 KiB |
Before Width: | Height: | Size: 184 KiB After Width: | Height: | Size: 184 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
@ -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,
|
||||
}
|
||||
}
|