diff --git a/Dockerfile b/Dockerfile index 145fddd..93da42e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,28 @@ # syntax=docker/dockerfile:1 +FROM python:3.11-alpine3.19 as compiler -FROM python:3.11-alpine +WORKDIR /app + +COPY src . + +RUN python3 -m compileall -b -f . && \ + find . -name "*.py" -type f -delete + +FROM python:3.11-alpine3.19 ENV PIP_NO_CACHE_DIR=off iSPBTV_docker=True iSPBTV_data_dir=data TERM=xterm-256color COLORTERM=truecolor COPY requirements.txt . RUN pip install --upgrade pip wheel && \ - pip install -r requirements.txt - + pip install -r requirements.txt && \ + pip uninstall -y pip wheel && \ + python3 -m compileall -b -f /usr/local/lib/python3.11/site-packages && \ + find /usr/local/lib/python3.11/site-packages -name "*.py" -type f -delete && \ + find /usr/local/lib/python3.11/ -name "__pycache__" -type d -exec rm -rf {} + WORKDIR /app -RUN python -m compileall +COPY --from=compiler /app . -COPY src . - -ENTRYPOINT ["python3", "-u", "main.py"] +ENTRYPOINT ["python3", "-u", "main.pyc"]