I dunno how to pro gram
6
.gitignore
vendored
|
@ -1,9 +1,10 @@
|
|||
### PostgreSQL template
|
||||
### Postgres template
|
||||
postgres
|
||||
|
||||
### Editors template
|
||||
.idea
|
||||
.vscode
|
||||
blogs
|
||||
|
||||
### Django template
|
||||
*.log
|
||||
|
@ -13,8 +14,9 @@ __pycache__/
|
|||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
media
|
||||
# media # By default you dont want this to be commited, but I run my server on Docker so bleh
|
||||
CACHE
|
||||
/data
|
||||
|
||||
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
|
||||
# in your Git repository. Update and uncomment the following line accordingly.
|
||||
|
|
17
README.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
My little Django website + blog
|
||||
|
||||
## Installation
|
||||
Clone this repo and cd into it
|
||||
|
||||
### Running
|
||||
```bash
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
### First time setup
|
||||
|
||||
```bash
|
||||
docker-compose exec website python3 /app/manage.py createsuperuser
|
||||
```
|
||||
|
||||
ok bye!
|
|
@ -5,21 +5,24 @@ services:
|
|||
image: postgres:alpine
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./postgres:/var/lib/postgresql/data
|
||||
- ./postgres/data:/var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
|
||||
|
||||
website:
|
||||
build: website
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./media:/website/media
|
||||
- ./logs:/data/logs
|
||||
- ./data/media:/website/media
|
||||
environment:
|
||||
DJANGO_KEY: ${DJANGO_KEY}
|
||||
DB_HOST: db
|
||||
DB_USER: ${POSTGRES_USER}
|
||||
DB_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
DB_NAME: ${POSTGRES_DB}
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
depends_on:
|
||||
- db
|
||||
ports:
|
||||
- "6212:8000"
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
Gunicorn
|
||||
psycopg2-binary
|
||||
pillow
|
||||
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,
|
||||
}
|
||||
}
|