From 5ca3c396ea3a9a25121d779777ba8a7a327fb077 Mon Sep 17 00:00:00 2001 From: Ajurna Date: Fri, 26 Aug 2022 16:08:48 +0100 Subject: [PATCH] Docker optimisation (#74) * optimised docker image. * bump version Co-authored-by: Peter Dwyer --- .dockerignore | 6 +++--- Dockerfile | 32 +++++++++++++++----------------- cbreader/settings/base.py | 5 ++--- docker-compose.yml | 2 +- pyproject.toml | 2 +- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/.dockerignore b/.dockerignore index e22a28f..9131383 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,6 @@ # Dockerignore whitelist * -!Pipfile -!Pipfile.lock !cbreader !comic !comic_auth @@ -15,4 +13,6 @@ !requirements.txt !package-lock.json !package.json -!frontend \ No newline at end of file +!frontend +/frontend/node_modules +/frontend/dist \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 005cb2e..4721124 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,36 @@ -FROM python:3 +FROM python:3.10-slim-bullseye ENV PYTHONFAULTHANDLER=1 \ PYTHONHASHSEED=random \ PYTHONUNBUFFERED=1 \ - PYTHONDONTWRITEBYTECODE=1 + PYTHONDONTWRITEBYTECODE=1 \ + PIP_DEFAULT_TIMEOUT=100 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 \ + PIP_NO_CACHE_DIR=1 RUN mkdir /src RUN mkdir /static WORKDIR /src -ENV PIP_DEFAULT_TIMEOUT=100 \ - PIP_DISABLE_PIP_VERSION_CHECK=1 \ - PIP_NO_CACHE_DIR=1 - -RUN apt update -RUN apt install -y software-properties-common -RUN apt-add-repository non-free -RUN apt update - -COPY requirements.txt /src - COPY . /src/ -RUN apt install -y npm cron unrar \ + +RUN apt update \ + && apt install -y software-properties-common \ + && apt-add-repository non-free \ + && apt update \ + && apt install -y npm cron unrar libmariadb-dev libpq-dev \ && pip install --upgrade pip \ && pip install -r requirements.txt \ && cd frontend \ && npm install \ && npm run build \ + && apt remove -y npm software-properties-common \ && rm -r node_modules \ - && apt -y auto-remove - -WORKDIR /src + && apt -y auto-remove \ + && apt clean \ + && rm -rf /var/lib/apt/lists/* RUN cat /src/cbreader/crontab >> /etc/cron.daily/cbreader diff --git a/cbreader/settings/base.py b/cbreader/settings/base.py index f7b23f1..f2e3bd4 100644 --- a/cbreader/settings/base.py +++ b/cbreader/settings/base.py @@ -117,7 +117,7 @@ LOGIN_URL = "/login/" UNRAR_TOOL = os.getenv("DJANGO_UNRAR_TOOL", None) -COMIC_BOOK_VOLUME = Path(os.getenv("COMIC_BOOK_VOLUME")) +COMIC_BOOK_VOLUME = Path(os.getenv("COMIC_BOOK_VOLUME", '/comics')) from .logger import LOGGING @@ -185,13 +185,12 @@ SIMPLE_JWT = { 'LEEWAY': timedelta(minutes=5), } -TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates') FRONTEND_DIR = os.path.join(BASE_DIR, 'frontend') TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [TEMPLATES_DIR, ], + "DIRS": [], "APP_DIRS": True, "OPTIONS": { "context_processors": [ diff --git a/docker-compose.yml b/docker-compose.yml index 2ca8a09..e7b9818 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,7 +35,7 @@ services: # command: /bin/bash entrypoint-cron.sh database: - image: postgres:11.4-alpine + image: postgres:14-alpine expose: - 5432 volumes: diff --git a/pyproject.toml b/pyproject.toml index 4612970..442222a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ line_length = 119 [tool.poetry] name = "cbwebreader" -version = "1.0.1" +version = "1.0.2" description = "CBR/Z Web Reader" authors = ["ajurna "] license = "Creative Commons Attribution-ShareAlike 4.0 International License"