diff --git a/gbapp/Dockerfile b/gbapp/Dockerfile new file mode 100644 index 0000000..cf5f0e8 --- /dev/null +++ b/gbapp/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.13 +WORKDIR /opt + +COPY requirements.txt ./ +COPY app.py ./ +COPY models.py ./ +COPY templates ./templates +COPY static ./static + +RUN apt-get update && apt-get -y install sqlite3 + +RUN pip install --no-cache-dir -r requirements.txt + +RUN useradd app +RUN chown -R app:app . + +EXPOSE 8000 + +USER app + +CMD ["sh", "-c", "sleep 10 && uvicorn app:app --host 0.0.0.0 --port 8000"] diff --git a/gbapp/__pycache__/app.cpython-313.pyc b/gbapp/__pycache__/app.cpython-313.pyc new file mode 100644 index 0000000..77dea11 Binary files /dev/null and b/gbapp/__pycache__/app.cpython-313.pyc differ diff --git a/gbapp/__pycache__/forms.cpython-313.pyc b/gbapp/__pycache__/forms.cpython-313.pyc new file mode 100644 index 0000000..1b05695 Binary files /dev/null and b/gbapp/__pycache__/forms.cpython-313.pyc differ diff --git a/gbapp/__pycache__/models.cpython-313.pyc b/gbapp/__pycache__/models.cpython-313.pyc new file mode 100644 index 0000000..49b1ca4 Binary files /dev/null and b/gbapp/__pycache__/models.cpython-313.pyc differ diff --git a/gbapp/__pycache__/ordinateur.cpython-313.pyc b/gbapp/__pycache__/ordinateur.cpython-313.pyc new file mode 100644 index 0000000..1f2a111 Binary files /dev/null and b/gbapp/__pycache__/ordinateur.cpython-313.pyc differ diff --git a/app.py b/gbapp/app.py similarity index 95% rename from app.py rename to gbapp/app.py index 1c6ac66..dfff502 100644 --- a/app.py +++ b/gbapp/app.py @@ -19,9 +19,16 @@ templates = Jinja2Templates(directory="templates") #sqlitemodel sqlite_file_name = "mydb.db" -sqlite_url = f"sqlite:///mydb.db" - -engine = create_engine(sqlite_url) +import os +pg_url = ( + f"postgresql+psycopg://" + f"{os.getenv('POSTGRES_USER')}:" + f"{os.getenv('POSTGRES_PASSWORD')}" + f"@db:5432/" + f"{os.getenv('POSTGRES_DB')}" +) +print(f"URL PGDB: {pg_url}") +engine = create_engine(pg_url) def create_db_and_tables(): SQLModel.metadata.create_all(engine) diff --git a/gbapp/gbcompose.yml b/gbapp/gbcompose.yml new file mode 100644 index 0000000..be1bb34 --- /dev/null +++ b/gbapp/gbcompose.yml @@ -0,0 +1,20 @@ +services: + grabber: + build: . + depends_on: + db: + condition: service_started + ports: + - "8080:80" + environment: + POSTGRES_USER: gb + POSTGRES_PASSWORD: gbpwd + POSTGRES_DB: gbdb + db: + image: postgres:18 + environment: + POSTGRES_USER: gb + POSTGRES_PASSWORD: gbpwd + POSTGRES_DB: gbdb + + diff --git a/models.py b/gbapp/models.py similarity index 93% rename from models.py rename to gbapp/models.py index 36540ed..fccf38a 100644 --- a/models.py +++ b/gbapp/models.py @@ -33,10 +33,7 @@ class ordinateur(SQLModel, table=True): cpu_freq_max: str = Field(index=True) cpu_id: str = Field(index=True) mb_serial: str = Field(index=True) - ram_size: str = Field(index=True) - ram_gen: str = Field(index=True) - sizes: str = Field(index=True) - memory_mb: str = Field(index=True) + ram: str = Field(index=True) gpu_model: str = Field(index=True) chassis_serial: str = Field(index=True) cpu_cores_nb: str = Field(index=True) diff --git a/requirements.txt b/gbapp/requirements.txt similarity index 93% rename from requirements.txt rename to gbapp/requirements.txt index 101e659..fd6055e 100644 --- a/requirements.txt +++ b/gbapp/requirements.txt @@ -9,7 +9,9 @@ greenlet==3.3.1 h11==0.16.0 idna==3.11 Jinja2==3.1.6 +lastapi==0.2 MarkupSafe==3.0.3 +psycopg[binary] pydantic==2.12.5 pydantic_core==2.41.5 python-multipart==0.0.22 diff --git a/templates/employee_form.html b/gbapp/templates/employee_form.html similarity index 100% rename from templates/employee_form.html rename to gbapp/templates/employee_form.html diff --git a/templates/employees.html b/gbapp/templates/employees.html similarity index 100% rename from templates/employees.html rename to gbapp/templates/employees.html diff --git a/templates/item.html b/gbapp/templates/item.html similarity index 84% rename from templates/item.html rename to gbapp/templates/item.html index 1990bd7..7717e05 100644 --- a/templates/item.html +++ b/gbapp/templates/item.html @@ -36,20 +36,8 @@