Basic docker.
authorRadek Czajka <rczajka@rczajka.pl>
Tue, 15 Apr 2025 13:51:33 +0000 (15:51 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Tue, 15 Apr 2025 13:51:33 +0000 (15:51 +0200)
Dockerfile [new file with mode: 0644]
Makefile
docker-compose.yml [new file with mode: 0644]

diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..032024b
--- /dev/null
@@ -0,0 +1,57 @@
+FROM python:3.8 AS base
+
+ARG UID=1000
+ARG GID=1000
+
+RUN     apt-get update && apt-get install -y \
+       git \
+       calibre \
+       texlive-xetex texlive-lang-polish \
+       libespeak-dev
+
+COPY requirements/requirements.txt requirements.txt
+
+# numpy -> aeneas
+RUN pip install numpy
+RUN pip install aeneas
+
+RUN pip install --no-cache-dir -r requirements.txt
+RUN pip install --no-cache-dir \
+    psycopg2-binary \
+    django-debug-toolbar==3.2.2 \
+    python-bidi
+
+RUN addgroup --gid $GID app
+RUN adduser --gid $GID --home /app --uid $UID app
+
+RUN     apt-get install -y \
+       texlive-extra-utils \
+       texlive-lang-greek \
+       texlive-lang-other \
+       texlive-luatex \
+       texlive-fonts-extra \
+       texlive-fonts-extra-links \
+       fonts-noto-core fonts-noto-extra
+
+
+USER app
+
+# fonts
+RUN cp -a /usr/local/lib/python*/site-packages/librarian/fonts /app/.fonts
+RUN fc-cache
+
+WORKDIR /app/src
+
+
+FROM base AS dev
+
+#RUN pip install --no-cache-dir coverage
+USER app
+
+
+FROM base AS prod
+
+RUN pip install --no-cache-dir gunicorn
+
+USER app
+COPY src /app/src
index d43ff1e..77d345d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,8 @@
-.PHONY: deploy test
+.PHONY: deploy test shell
+
+
+UID != id -u
+GID != id -g
 
 
 deploy: src/wolnelektury/localsettings.py
@@ -17,3 +21,11 @@ test:
        mv ../htmlcov.new ../htmlcov
        coverage report
        rm .coverage
+
+
+shell:
+       UID=$(UID) GID=$(GID) docker-compose run --rm dev bash
+
+
+build:
+       UID=$(UID) GID=$(GID) docker-compose build dev
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644 (file)
index 0000000..89b2216
--- /dev/null
@@ -0,0 +1,22 @@
+services:
+  dev:
+    build:
+      context: .
+      target: dev
+      args:
+        - "UID=${UID}"
+        - "GID=${GID}"
+    volumes:
+      - ./src:/app/src
+      - ./var/media:/app/var/media
+      - ./var/static:/app/var/static
+      - ./var/counters/:/app/var/counters
+    depends_on:
+      - db
+  db:
+    image: postgres
+    container_name: db
+    env_file:
+      - .env
+    volumes:
+      - ./var/postgresql-data/:/var/lib/postgresql/data/