Adding docker files

This commit is contained in:
Apoclyps
2019-07-24 07:04:23 +01:00
parent 4287ae3153
commit 950256fa4a
4 changed files with 79 additions and 13 deletions

10
.dockerignore Normal file
View File

@@ -0,0 +1,10 @@
# Dockerignore whitelist
*
!Pipfile
!Pipfile.lock
!cbreader
!comic
!comic_auth
!manage.py
!pytest

View File

@@ -1,16 +1,28 @@
FROM python:3-alpine
ENV PYTHONUNBUFFERED 1
RUN apk update
RUN apk add --no-cache tini bash unrar dcron postgresql-dev
RUN mkdir /src
WORKDIR /src
ADD Pipfile /src
ADD Pipfile.lock /src
RUN apk add --no-cache tini bash unrar dcron postgresql-dev gcc python3-dev musl-dev
RUN apk add --no-cache --virtual .build-deps mariadb-dev build-base \
&& pip install pipenv \
&& pipenv install --system \
&& apk add --virtual .runtime-deps mariadb-connector-c-dev mariadb-connector-c \
&& apk del .build-deps
ADD . /src/
RUN mkdir /src
WORKDIR /src
ADD Pipfile /src
ADD Pipfile.lock /src
RUN pipenv install --deploy --dev --ignore-pipfile --system
COPY . /src/
RUN cat /src/cbreader/crontab >> /etc/crontabs/root
EXPOSE 8000

View File

@@ -13,6 +13,8 @@ https://docs.djangoproject.com/en/1.8/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import dj_database_url
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -76,12 +78,17 @@ WSGI_APPLICATION = 'cbreader.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
DATABASE_URL = os.getenv("DATABASE_URL")
if DATABASE_URL:
DATABASES = {"default": dj_database_url.config(conn_max_age=500)}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
}
# Internationalization

37
docker-compose.yml Normal file
View File

@@ -0,0 +1,37 @@
version: '3.7'
services:
app:
build: .
environment:
- DATABASE_URL=postgres://admin:password@database:5432/cbwebreader
- DJANGO_SETTINGS_MODULE=cbreader.settings
links:
- database
depends_on:
- database
ports:
- "8000:8000"
volumes:
- ./cbreader:/src/cbreader
- ./comic:/src/comic
- ./comic_auth:/src/comic_auth
- D:\Downloads\comics:/data
command: python manage.py runserver 0.0.0.0:8000
database:
image: postgres:11.4-alpine
ports:
- 5432:5432
volumes:
- /var/lib/postgresql/data
environment:
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=password
- POSTGRES_DB=cbwebreader
# volumes:
# comic-volume:
# name: comic-volume
# external: true