feat: Package into a container
This commit is contained in:
parent
362e9792e9
commit
9b63e2b0b2
6 changed files with 33 additions and 3 deletions
5
.containerignore
Normal file
5
.containerignore
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
/db
|
||||||
|
/dumps
|
||||||
|
/env
|
||||||
|
__pycache__
|
||||||
|
.env*
|
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
||||||
env
|
/db
|
||||||
|
/dumps
|
||||||
|
/env
|
||||||
__pycache__
|
__pycache__
|
||||||
*.sqlite3
|
.env*
|
||||||
|
|
15
Containerfile
Normal file
15
Containerfile
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
FROM docker.io/python:3.9-alpine
|
||||||
|
|
||||||
|
# Allows docker to cache installed dependencies between builds
|
||||||
|
COPY requirements.txt requirements.txt
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
COPY . code
|
||||||
|
WORKDIR /code
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
RUN python3 /code/manage.py collectstatic --no-input
|
||||||
|
|
||||||
|
ENTRYPOINT ["gunicorn"]
|
||||||
|
CMD ["djangotea.wsgi:application", "--bind=0.0.0.0:8000"]
|
0
db/.gitkeep
Normal file
0
db/.gitkeep
Normal file
|
@ -29,6 +29,10 @@ ALLOWED_HOSTS = [
|
||||||
'*',
|
'*',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
CSRF_TRUSTED_ORIGINS = [
|
||||||
|
os.environ.get('CSRF_TRUSTED_ORIGINS')
|
||||||
|
]
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
@ -45,6 +49,7 @@ INSTALLED_APPS = [
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
"whitenoise.middleware.WhiteNoiseMiddleware",
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
@ -80,7 +85,7 @@ WSGI_APPLICATION = 'djangotea.wsgi.application'
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"),
|
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"),
|
||||||
"NAME": os.environ.get("SQL_DATABASE", os.path.join(BASE_DIR, "db.sqlite3")),
|
"NAME": os.environ.get("SQL_DATABASE", os.path.join(BASE_DIR, "db", "db.sqlite3")),
|
||||||
"USER": os.environ.get("SQL_USER", "user"),
|
"USER": os.environ.get("SQL_USER", "user"),
|
||||||
"PASSWORD": os.environ.get("SQL_PASSWORD", "password"),
|
"PASSWORD": os.environ.get("SQL_PASSWORD", "password"),
|
||||||
"HOST": os.environ.get("SQL_HOST", "localhost"),
|
"HOST": os.environ.get("SQL_HOST", "localhost"),
|
||||||
|
@ -124,6 +129,7 @@ USE_TZ = True
|
||||||
# https://docs.djangoproject.com/en/4.0/howto/static-files/
|
# https://docs.djangoproject.com/en/4.0/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = 'static/'
|
STATIC_URL = 'static/'
|
||||||
|
STATIC_ROOT = os.path.join(BASE_DIR, "static")
|
||||||
|
|
||||||
# Default primary key field type
|
# Default primary key field type
|
||||||
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
Django==4.0.2
|
Django==4.0.2
|
||||||
|
whitenoise==6.0.0
|
||||||
|
gunicorn==20.1.0
|
||||||
|
|
Reference in a new issue