better build, multi stage, passing args in compose

This commit is contained in:
simon 2022-12-22 10:19:00 +07:00
parent 1a32b0a51d
commit 35a90941ff
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
3 changed files with 25 additions and 9 deletions

View File

@ -12,7 +12,10 @@ services:
# main flask site # main flask site
tubearchivist: tubearchivist:
container_name: tubearchivist container_name: tubearchivist
build: ./tubearchivist/web build:
context: ./tubearchivist/web
args:
- INSTALL_DEBUG=1
restart: always restart: always
volumes: volumes:
- ./volume/tubearchivist/data:/data - ./volume/tubearchivist/data:/data

View File

@ -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 && \ RUN apt-get update && apt-get install -y --no-install-recommends \
apt-get -y install --no-install-recommends \ build-essential
build-essential libpq-dev vim htop bmon net-tools iputils-ping procps
ENV PATH=/root/.local/bin:$PATH
COPY requirements.txt /requirements.txt 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 RUN mkdir /data

View File

@ -1,9 +1,8 @@
APScheduler==3.9.1.post1 APScheduler==3.9.1.post1
beautifulsoup4==4.11.1 beautifulsoup4==4.11.1
flask==2.2.2 flask==2.2.2
ipython==8.7.0
markdown==3.4.1 markdown==3.4.1
psycopg2==2.9.5 psycopg2-binary==2.9.5
redis==4.4.0 redis==4.4.0
requests==2.28.1 requests==2.28.1
uWSGI==2.0.21 uWSGI==2.0.21