Retour à pip install au lieu de Poetry

This commit is contained in:
François Pelletier 2025-01-08 14:14:51 -05:00
parent 2a7b056698
commit a5403db464
11 changed files with 158 additions and 3958 deletions

View file

@ -17,21 +17,14 @@ RUN apt-get -y update && apt-get install -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
# Add Poetry to PATH
ENV PATH="/root/.local/bin:$PATH"
# Set the working directory
WORKDIR /app
# Copy only pyproject.toml and poetry.lock (if it exists)
COPY pyproject.toml poetry.lock* ./
# Copier les fichiers de configuration de Poetry
COPY requirements.txt .
# Install project dependencies
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi
# Installer les dépendances
RUN pip install -r requirements.txt
# Policy for ImageMagick
COPY conf/policy.xml /etc/ImageMagick-6/policy.xml
@ -49,4 +42,4 @@ COPY *.py .
COPY *.lua .
# Run the application
CMD ["poetry", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]

2462
backend/poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,105 +0,0 @@
[tool.poetry]
name = "fabriquedoc-backend"
version = "0.1.0"
description = "Backend for FabriqueDoc"
authors = ["Your Name <your.email@example.com>"]
[tool.poetry.dependencies]
python = "^3.13"
altair = "5.5.0"
annotated-types = "0.7.0"
anyio = "4.7.0"
attrs = "24.3.0"
blinker = "1.9.0"
build = "1.2.2.post1"
CacheControl = "0.14.1"
cachetools = "5.5.0"
certifi = "2024.12.14"
cffi = "1.17.1"
charset-normalizer = "3.4.1"
cleo = "2.1.0"
click = "8.1.8"
crashtest = "0.4.1"
distlib = "0.3.9"
dulwich = "0.21.7"
emoji = "2.14.0"
fastapi = "0.115.6"
fastjsonschema = "2.21.1"
filelock = "3.16.1"
gitdb = "4.0.11"
GitPython = "3.1.43"
h11 = "0.14.0"
httpcore = "1.0.7"
httpx = "0.28.1"
idna = "3.10"
installer = "0.7.0"
jaraco-classes = "3.4.0"
Jinja2 = "3.1.5"
jsonschema = "4.23.0"
jsonschema-specifications = "2024.10.1"
keyring = "24.3.1"
markdown-it-py = "3.0.0"
MarkupSafe = "3.0.2"
mdformat = "0.7.21"
mdurl = "0.1.2"
more-itertools = "10.5.0"
msgpack = "1.1.0"
narwhals = "1.20.1"
numpy = "2.2.1"
opencv-python = "4.10.0.84"
packaging = "24.2"
pandas = "2.2.3"
passlib = "1.7.4"
pexpect = "4.9.0"
pillow = "11.0.0"
pkginfo = "1.12.0"
platformdirs = "4.3.6"
poetry = "1.8.5"
poetry-core = "1.9.1"
poetry-plugin-export = "1.8.0"
protobuf = "5.29.2"
ptyprocess = "0.7.0"
pyarrow = "18.1.0"
pycparser = "2.22"
pydantic = "2.10.4"
pydantic_core = "2.27.2"
pydeck = "0.9.1"
Pygments = "2.18.0"
PyJWT = "2.10.1"
pypandoc = "1.14"
pyproject_hooks = "1.2.0"
python-dateutil = "2.9.0.post0"
python-dotenv = "1.0.1"
python-multipart = "0.0.20"
pytz = "2024.2"
RapidFuzz = "3.11.0"
referencing = "0.35.1"
requests = "2.32.3"
requests-toolbelt = "1.0.0"
rich = "13.9.4"
rpds-py = "0.22.3"
shellingham = "1.5.4"
six = "1.17.0"
smmap = "5.0.1"
sniffio = "1.3.1"
starlette = "0.41.3"
streamlit = "1.41.1"
tenacity = "9.0.0"
toml = "0.10.2"
tomlkit = "0.13.2"
tornado = "6.4.2"
trove-classifiers = "2024.10.21.16"
typing_extensions = "4.12.2"
tzdata = "2024.2"
urllib3 = "2.3.0"
uvicorn = "0.34.0"
virtualenv = "20.28.0"
Wand = "0.6.13"
xattr = "1.1.0"
[tool.poetry.dev-dependencies]
# Add any development dependencies here
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

92
backend/requirements.txt Normal file
View file

@ -0,0 +1,92 @@
altair
annotated-types
anyio
attrs
blinker
build
CacheControl
cachetools
certifi
cffi
charset-normalizer
cleo
click
crashtest
distlib
dulwich
emoji
fastapi
fastjsonschema
filelock
gitdb
GitPython
h11
httpcore
httpx
idna
installer
jaraco.classes
jaraco.context
jaraco.functools
Jinja2
jsonschema
jsonschema-specifications
keyring
markdown-it-py
MarkupSafe
mdformat
mdurl
more-itertools
msgpack
narwhals
numpy
opencv-python
packaging
pandas
passlib
pexpect
pillow
pkginfo
platformdirs
poetry
poetry-core
poetry-plugin-export
protobuf
ptyprocess
pyarrow
pycparser
pydantic
pydantic_core
pydeck
Pygments
PyJWT
pypandoc
pyproject_hooks
python-dateutil
python-dotenv
python-multipart
pytz
RapidFuzz
referencing
requests
requests-toolbelt
rich
rpds-py
shellingham
six
smmap
sniffio
starlette
streamlit
tenacity
toml
tomlkit
tornado
trove-classifiers
typing_extensions
tzdata
urllib3
uvicorn
virtualenv
Wand
xattr

View file

@ -12,6 +12,8 @@ services:
- USERNAME=${USERNAME}
- PASS_HASH=${PASS_HASH}
- ALGORITHM=${ALGORITHM}
networks:
- fabriquedoc
frontend:
build:
@ -23,3 +25,9 @@ services:
- backend
environment:
- FABRIQUEDOC_ENDPOINT=${FABRIQUEDOC_ENDPOINT}
networks:
- fabriquedoc
networks:
fabriquedoc:
name: fabriquedoc

View file

@ -1,19 +1,6 @@
# Utiliser l'image Python 3.13 slim officielle comme base
FROM python:3.13-slim
# Définir des variables d'environnement
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
POETRY_VERSION=1.5.1 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1 \
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv"
# Définir le répertoire de travail dans le conteneur
WORKDIR /app
# Installer les dépendances système nécessaires
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
@ -21,25 +8,23 @@ RUN apt-get update \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Installer Poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="${POETRY_HOME}/bin:${PATH}"
# Set the working directory
WORKDIR /app
# Copier les fichiers de configuration de Poetry
COPY pyproject.toml poetry.lock* ./
COPY requirements.txt .
# Installer les dépendances du projet
RUN poetry config virtualenvs.create false \
&& poetry install --no-dev --no-interaction --no-ansi
# Installer les dépendances
RUN pip install -r requirements.txt
# Copier le code de l'application
COPY . .
COPY *.py .
# Exposer le port sur lequel Streamlit s'exécutera
EXPOSE 8051
# Définir l'entrypoint pour exécuter l'application
ENTRYPOINT ["poetry", "run", "streamlit", "run"]
ENTRYPOINT ["streamlit", "run"]
# Définir la commande par défaut avec les options optimisées pour Streamlit
CMD ["main.py", \

1336
frontend/poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,20 +0,0 @@
[tool.poetry]
name = "fabriquedoc-frontend"
version = "0.1.0"
description = "Frontend pour FabriqueDoc"
authors = ["François Pelletier <votre.email@example.com>"]
[tool.poetry.dependencies]
python = "^3.13"
streamlit = "^1.24.0"
requests = "^2.31.0"
python-dotenv = "^1.0.0"
pydantic = "^2.0.0"
mdformat = "^0.7.16"
[tool.poetry.dev-dependencies]
# Ajoutez ici vos dépendances de développement si nécessaire
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

View file

@ -0,0 +1,5 @@
streamlit
requests
python-dotenv
pydantic
mdformat

View file

@ -12,8 +12,23 @@ def hash_password(password):
# Combine salt and hash, and encode in base64
return base64.b64encode(salt + hashed).decode('utf-8')
def update_env_file(hashed_password):
env_path = os.path.join(os.path.dirname(__file__), '.env')
with open(env_path, 'r') as file:
lines = file.readlines()
with open(env_path, 'w') as file:
for line in lines:
if line.startswith('PASS_HASH='):
file.write(f'PASS_HASH={hashed_password}\n')
else:
file.write(line)
if __name__ == "__main__":
password = input("Enter the password to hash: ")
hashed_password = hash_password(password)
print(f"Hashed password: {hashed_password}")
print("Add this to your .env file as PASS_HASH=<hashed_password>")
update_env_file(hashed_password)
print("The .env file has been updated with the new PASS_HASH.")

25
generate_secret_key.py Normal file
View file

@ -0,0 +1,25 @@
import secrets
import os
def generate_secret_key():
return secrets.token_hex(16) # 16 bytes = 32 hex characters
def update_env_file(secret_key):
env_path = os.path.join(os.path.dirname(__file__), '.env')
with open(env_path, 'r') as file:
lines = file.readlines()
with open(env_path, 'w') as file:
for line in lines:
if line.startswith('SECRET_KEY='):
file.write(f'SECRET_KEY={secret_key}\n')
else:
file.write(line)
if __name__ == "__main__":
new_secret_key = generate_secret_key()
print(f"Generated Secret Key: {new_secret_key}")
update_env_file(new_secret_key)
print("The .env file has been updated with the new SECRET_KEY.")