feat: várias melhorias e evoluções no projeto

This commit is contained in:
root
2025-05-26 14:22:19 +02:00
parent 78e994eb6a
commit 9dca0d6022
108 changed files with 2601 additions and 2131 deletions

View File

@ -1,28 +1,28 @@
# define an alias for the specific python version used in this file.
FROM docker.io/python:3.12.9-slim-bookworm AS python
# FROM docker.io/python:3.12.9-slim-bookworm AS python # Linha removida, já definida abaixo
# Python build stage
FROM python AS python-build-stage
# Python build stage - Mantenha apenas dependências de BUILD aqui
FROM docker.io/python:3.12.9-slim-bookworm AS python-build-stage
ARG BUILD_ENVIRONMENT=local
# Install apt packages
# Instalar apenas dependências para construir pacotes Python
RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
# psycopg dependencies
libpq-dev
build-essential \
libpq-dev \
# libtesseract-dev pode ser necessário aqui se alguma lib Python compila contra ele
libtesseract-dev \
&& rm -rf /var/lib/apt/lists/*
# Requirements are installed here to ensure they will be cached.
# Requirements são instalados aqui para garantir que serão cacheados.
COPY ./requirements .
# Create Python Dependency and Sub-Dependency Wheels.
# Criar Wheels das dependências Python.
RUN pip wheel --wheel-dir /usr/src/app/wheels \
-r ${BUILD_ENVIRONMENT}.txt
-r ${BUILD_ENVIRONMENT}.txt
# Python 'run' stage
FROM python AS python-run-stage
# Python 'run' stage - ESTA É A IMAGEM FINAL
FROM docker.io/python:3.12.9-slim-bookworm AS python-run-stage
ARG BUILD_ENVIRONMENT=local
ARG APP_HOME=/app
@ -33,48 +33,46 @@ ENV BUILD_ENV=${BUILD_ENVIRONMENT}
WORKDIR ${APP_HOME}
# devcontainer dependencies and utils
# Instalar TODAS as dependências de sistema necessárias em TEMPO DE EXECUÇÃO
RUN apt-get update && apt-get install --no-install-recommends -y \
sudo git bash-completion nano ssh
# Dependências do psycopg e outras utilidades
libpq-dev \
wait-for-it \
gettext \
poppler-utils \
unpaper \
tesseract-ocr \
tesseract-ocr-por \
ghostscript \
# libtesseract-dev \
# Utilitários do devcontainer e outros
sudo git bash-completion vim ssh \
# Limpeza
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
# Create devcontainer user and add it to sudoers
# Criar usuário devcontainer (manter como está)
RUN groupadd --gid 1000 dev-user \
&& useradd --uid 1000 --gid dev-user --shell /bin/bash --create-home dev-user \
&& echo dev-user ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/dev-user \
&& chmod 0440 /etc/sudoers.d/dev-user
&& useradd --uid 1000 --gid dev-user --shell /bin/bash --create-home dev-user \
&& echo dev-user ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/dev-user \
&& chmod 0440 /etc/sudoers.d/dev-user
# Install required system dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \
# psycopg dependencies
libpq-dev \
wait-for-it \
# Translations dependencies
gettext \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
# All absolute dir copies ignore workdir instruction. All relative dir copies are wrt to the workdir instruction
# copy python dependency wheels from python-build-stage
# Instalar dependências Python a partir dos wheels (manter como está)
COPY --from=python-build-stage /usr/src/app/wheels /wheels/
# use wheels to install python dependencies
RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
&& rm -rf /wheels/
&& rm -rf /wheels/
# Copiar scripts e código (manter como está)
COPY ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint
RUN chmod +x /entrypoint
COPY ./compose/local/django/start /start
RUN sed -i 's/\r$//g' /start
RUN chmod +x /start
# copy application code to WORKDIR
COPY . ${APP_HOME}
# REMOVER esta linha, poppler-utils já foi instalado acima
# RUN apt-get update && apt-get install -y poppler-utils
ENTRYPOINT ["/entrypoint"]