From 35a90941fff5111ffc852175958b0db9c0247548 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 22 Dec 2022 10:19:00 +0700 Subject: [PATCH] better build, multi stage, passing args in compose --- docker-compose_testing.yml | 5 ++++- tubearchivist/web/Dockerfile | 26 ++++++++++++++++++++------ tubearchivist/web/requirements.txt | 3 +-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/docker-compose_testing.yml b/docker-compose_testing.yml index fb183d5..02444c3 100644 --- a/docker-compose_testing.yml +++ b/docker-compose_testing.yml @@ -12,7 +12,10 @@ services: # main flask site tubearchivist: container_name: tubearchivist - build: ./tubearchivist/web + build: + context: ./tubearchivist/web + args: + - INSTALL_DEBUG=1 restart: always volumes: - ./volume/tubearchivist/data:/data diff --git a/tubearchivist/web/Dockerfile b/tubearchivist/web/Dockerfile index b9919da..2240566 100644 --- a/tubearchivist/web/Dockerfile +++ b/tubearchivist/web/Dockerfile @@ -1,12 +1,26 @@ -FROM python:3.10.8-slim-bullseye +# builder +FROM python:3.10.8-slim-bullseye as builder -RUN apt-get clean && apt-get -y update && \ - apt-get -y install --no-install-recommends \ - build-essential libpq-dev vim htop bmon net-tools iputils-ping procps +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential -ENV PATH=/root/.local/bin:$PATH COPY requirements.txt /requirements.txt -RUN pip install --upgrade pip && pip install --user -r requirements.txt +RUN pip install --user -r requirements.txt + +# final +FROM python:3.10.8-slim-bullseye as tubearchivist-web + +ARG INSTALL_DEBUG +ENV PYTHONUNBUFFERED 1 + +COPY --from=builder /root/.local /root/.local +ENV PATH=/root/.local/bin:$PATH + +RUN if [ "$INSTALL_DEBUG" ] ; then \ + apt-get -y update && apt-get -y install --no-install-recommends \ + vim htop bmon net-tools iputils-ping procps \ + && pip install --user ipython \ + ; fi RUN mkdir /data diff --git a/tubearchivist/web/requirements.txt b/tubearchivist/web/requirements.txt index 27ad8e8..a229d38 100644 --- a/tubearchivist/web/requirements.txt +++ b/tubearchivist/web/requirements.txt @@ -1,9 +1,8 @@ APScheduler==3.9.1.post1 beautifulsoup4==4.11.1 flask==2.2.2 -ipython==8.7.0 markdown==3.4.1 -psycopg2==2.9.5 +psycopg2-binary==2.9.5 redis==4.4.0 requests==2.28.1 uWSGI==2.0.21