I dunno how to pro gram
6
.gitignore
vendored
|
@ -1,9 +1,10 @@
|
||||||
### PostgreSQL template
|
### Postgres template
|
||||||
postgres
|
postgres
|
||||||
|
|
||||||
### Editors template
|
### Editors template
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
|
blogs
|
||||||
|
|
||||||
### Django template
|
### Django template
|
||||||
*.log
|
*.log
|
||||||
|
@ -13,8 +14,9 @@ __pycache__/
|
||||||
local_settings.py
|
local_settings.py
|
||||||
db.sqlite3
|
db.sqlite3
|
||||||
db.sqlite3-journal
|
db.sqlite3-journal
|
||||||
media
|
# media # By default you dont want this to be commited, but I run my server on Docker so bleh
|
||||||
CACHE
|
CACHE
|
||||||
|
/data
|
||||||
|
|
||||||
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
|
# 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.
|
# 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
|
image: postgres:alpine
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./postgres:/var/lib/postgresql/data
|
- ./postgres/data:/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}
|
||||||
|
|
||||||
|
|
||||||
website:
|
website:
|
||||||
build: website
|
build: website
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./media:/website/media
|
- ./data/media:/website/media
|
||||||
- ./logs:/data/logs
|
|
||||||
environment:
|
environment:
|
||||||
DJANGO_KEY: ${DJANGO_KEY}
|
DJANGO_KEY: ${DJANGO_KEY}
|
||||||
DB_HOST: db
|
POSTGRES_USER: ${POSTGRES_USER}
|
||||||
DB_USER: ${POSTGRES_USER}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
DB_PASSWORD: ${POSTGRES_PASSWORD}
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
DB_NAME: ${POSTGRES_DB}
|
depends_on:
|
||||||
|
- db
|
||||||
|
ports:
|
||||||
|
- "6212:8000"
|
||||||
|
|
|
@ -2,12 +2,17 @@
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
EXPOSE 8000
|
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 requirements.txt requirements.txt
|
||||||
COPY ./website ./website
|
|
||||||
|
|
||||||
RUN apk update && apk add python3 py3-pip
|
|
||||||
RUN pip install -r requirements.txt
|
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
|
Gunicorn
|
||||||
psycopg2-binary
|
|
||||||
pillow
|
|
||||||
django
|
django
|
||||||
|
psycopg2-binary
|
||||||
|
tzdata
|
||||||
|
pillow
|
||||||
django-libsass
|
django-libsass
|
||||||
django-compressor
|
django-compressor
|
||||||
django-markdownify
|
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
|
# Database
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
||||||
|
|
||||||
# DATABASES = {
|
|
||||||
# "default": {
|
|
||||||
# "ENGINE": "django.db.backends.sqlite3",
|
|
||||||
# "NAME": BASE_DIR / "db.sqlite3",
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
'ENGINE': "django.db.backends.postgresql",
|
||||||
'NAME': getenv('POSTGRES_DB'),
|
'NAME': getenv('POSTGRES_DB'),
|
||||||
'USER': getenv('POSTGRES_USER'),
|
'USER': getenv('POSTGRES_USER'),
|
||||||
'PASSWORD': getenv('POSTGRES_PASSWORD'),
|
'PASSWORD': getenv('POSTGRES_PASSWORD'),
|
||||||
'HOST': getenv('POSTGRES_HOST'),
|
'HOST': 'db',
|
||||||
'PORT': 5432,
|
'PORT': 5432,
|
||||||
}
|
}
|
||||||
}
|
}
|