Dockerize app

This commit is contained in:
Mouse Reeve 2020-03-22 11:21:19 -07:00
parent eac8f2a2f9
commit 6aad1c9250
4 changed files with 46 additions and 25 deletions

View file

@ -1,18 +1,23 @@
# SECURITY WARNING: keep the secret key used in production secret!
export SECRET_KEY="7(2w1sedok=aznpq)ta1mc4i%4h=xx@hxwx*o57ctsuml0x%fr"
SECRET_KEY="7(2w1sedok=aznpq)ta1mc4i%4h=xx@hxwx*o57ctsuml0x%fr"
# SECURITY WARNING: don't run with debug turned on in production!
export DEBUG=true
DEBUG=true
export DOMAIN=your.domain.here
DOMAIN=your.domain.here
## Leave unset to allow all hosts
# export ALLOWED_HOSTS="localhost,127.0.0.1,[::1]"
# ALLOWED_HOSTS="localhost,127.0.0.1,[::1]"
export OL_URL="https://openlibrary.org"
OL_URL="https://openlibrary.org"
## Database backend to use.
## Default is postgres, sqlite is for dev quickstart only (NOT production!!!)
export FEDIREADS_DATABASE_BACKEND=postgres
FEDIREADS_DATABASE_BACKEND=postgres
MEDIA_ROOT="images/"
POSTGRES_PASSWORD="fedireads"
POSTGRES_USER="postgres"
POSTGRES_DB="postgres"
export MEDIA_ROOT="images/"

7
Dockerfile Normal file
View file

@ -0,0 +1,7 @@
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY ./fedireads /code

19
docker-compose.yml Normal file
View file

@ -0,0 +1,19 @@
version: '3'
services:
db:
image: postgres
env_file: .env
volumes:
- pgdata:/var/lib/posgresql/data
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
volumes:
pgdata:

View file

@ -70,25 +70,15 @@ WSGI_APPLICATION = 'fedireads.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
FEDIREADS_DATABASE_BACKEND = env('FEDIREADS_DATABASE_BACKEND', 'postgres')
FEDIREADS_DBS = {
'postgres': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'fedireads',
'USER': 'fedireads',
'PASSWORD': 'fedireads',
'HOST': '',
'PORT': 5432
},
'sqlite': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'fedireads.db')
}
}
DATABASES = {
'default': FEDIREADS_DBS[FEDIREADS_DATABASE_BACKEND]
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': '"%s"' % env('POSTGRES_PASSWORD', 'fedireads'),
'HOST': 'db',
'PORT': 5432
}
}
LOGIN_URL = '/login/'