Make a deployable version
This commit is contained in:
parent
92475c508b
commit
17630e965b
8 changed files with 86 additions and 7 deletions
7
.env.production
Normal file
7
.env.production
Normal file
|
@ -0,0 +1,7 @@
|
|||
SECRET_KEY=....
|
||||
DB_PATH=/data/db.sqlite3
|
||||
MEDIA_ROOT=/uploads/media
|
||||
DJANGO_ALLOWED_HOSTS=*
|
||||
DJANGO_CSRF_TRUSTED_ORIGINS=http://
|
||||
DJANGO_SETTINGS_MODULE=iamkonstantin_web.settings.production
|
||||
DJANGO_LOG_LEVEL=INFO
|
|
@ -2,7 +2,7 @@
|
|||
FROM python:3.8.1-slim-buster
|
||||
|
||||
# Add user that will be used in the container.
|
||||
RUN useradd wagtail
|
||||
# RUN useradd wagtail
|
||||
|
||||
# Port used by this container to serve HTTP.
|
||||
EXPOSE 8000
|
||||
|
@ -37,13 +37,13 @@ WORKDIR /app
|
|||
# Set this directory to be owned by the "wagtail" user. This Wagtail project
|
||||
# uses SQLite, the folder needs to be owned by the user that
|
||||
# will be writing to the database file.
|
||||
RUN chown wagtail:wagtail /app
|
||||
# RUN chown wagtail:wagtail /app
|
||||
|
||||
# Copy the source code of the project into the container.
|
||||
COPY --chown=wagtail:wagtail . .
|
||||
COPY . .
|
||||
|
||||
# Use user "wagtail" to run the build commands below and the server itself.
|
||||
USER wagtail
|
||||
# USER wagtail
|
||||
|
||||
# Collect static files.
|
||||
RUN python manage.py collectstatic --noinput --clear
|
||||
|
|
10
Makefile
Normal file
10
Makefile
Normal file
|
@ -0,0 +1,10 @@
|
|||
.PHONY: help build publish
|
||||
|
||||
help:
|
||||
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
build:
|
||||
@docker build -t code.headbright.be/konstantin/iamkonstantin:1.0.6 .
|
||||
|
||||
publish:
|
||||
@docker push code.headbright.be/konstantin/iamkonstantin:1.0.6
|
11
README.md
Normal file
11
README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
```shell
|
||||
caddy reverse-proxy --to :8000
|
||||
```
|
||||
|
||||
Caddyfile
|
||||
|
||||
```
|
||||
iamkonstantin.eu
|
||||
|
||||
reverse_proxy :8000
|
||||
```
|
|
@ -2,13 +2,16 @@ version: '3.8'
|
|||
|
||||
services:
|
||||
wagtail:
|
||||
image: code.headbright.be/konstantin/iamkonstantin:1.0.0
|
||||
image: code.headbright.be/konstantin/iamkonstantin:1.0.6
|
||||
container_name: wagtail
|
||||
restart: always
|
||||
volumes:
|
||||
- ./website/:/usr/src/app/:consistent
|
||||
- ./database:/data:rw
|
||||
- /var/uploads:/uploads/media:rw
|
||||
ports:
|
||||
- 8000:8000
|
||||
command : python manage.py runserver 0.0.0.0:8000
|
||||
command : bash -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
|
||||
env_file:
|
||||
- ./.env.production
|
||||
networks:
|
||||
|
|
|
@ -2,6 +2,53 @@ from .base import *
|
|||
|
||||
DEBUG = False
|
||||
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": os.environ["DB_PATH"],
|
||||
}
|
||||
}
|
||||
|
||||
MEDIA_ROOT = os.environ["MEDIA_ROOT"]
|
||||
|
||||
# WAGTAILDOCS_SERVE_METHOD = 'serve_view'
|
||||
|
||||
print("using database path {}".format(os.environ["DB_PATH"]))
|
||||
print("using media root path {}".format(os.environ["MEDIA_ROOT"]))
|
||||
|
||||
SECRET_KEY = os.environ["SECRET_KEY"]
|
||||
|
||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||
|
||||
SECURE_SSL_REDIRECT = True
|
||||
|
||||
ALLOWED_HOSTS = os.getenv("DJANGO_ALLOWED_HOSTS", "*").split(",")
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = os.getenv("DJANGO_CSRF_TRUSTED_ORIGINS", "").split(",")
|
||||
|
||||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||
|
||||
MIDDLEWARE.append("whitenoise.middleware.WhiteNoiseMiddleware")
|
||||
STORAGES["staticfiles"]["BACKEND"] = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
||||
|
||||
LOGGING = {
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
"handlers": {
|
||||
"console": {
|
||||
"class": "logging.StreamHandler",
|
||||
},
|
||||
},
|
||||
"loggers": {
|
||||
"django": {
|
||||
"handlers": ["console"],
|
||||
"level": os.getenv("DJANGO_LOG_LEVEL", "INFO"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
WAGTAIL_REDIRECTS_FILE_STORAGE = "cache"
|
||||
|
||||
try:
|
||||
from .local import *
|
||||
except ImportError:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% load navigation_tags %}
|
||||
|
||||
<footer>
|
||||
<p>Built with Wagtail</p>
|
||||
<p>Hello 👋</p>
|
||||
|
||||
{% with linkedin_url=settings.base.NavigationSettings.linkedin_url github_url=settings.base.NavigationSettings.github_url mastodon_url=settings.base.NavigationSettings.mastodon_url %}
|
||||
{% if linkedin_url or github_url or mastodon_url %}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
Django>=4.2,<5.1
|
||||
wagtail>=6.0,<6.1
|
||||
whitenoise>=6.6,<7.0
|
Loading…
Add table
Add a link
Reference in a new issue