1.8 KiB
[Jeudi 26 Février 2026]
dockerisation de l'appli avec tout les paramètres
- [Commande du jour]
docker build -t grabber:latest .
Explanation
A Dockerfile is a text-based document that's used to create a container image. It provides instructions to the image builder on the commands to run, files to copy, startup command, and more.
As an example, the following Dockerfile would produce a ready-to-run Python application:
FROM python:3.13.5 WORKDIR /usr/local/app
Install the application dependencies
COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt
Copy in the source code
COPY src ./src EXPOSE 8080
Setup an app user so the container doesn't run as the root user
RUN useradd app USER app
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"]
- [DOCKER DOCKER DOCKER]
docker build -t grabber-app . docker build -t grabber:latest . docker run -dit --name grabber grabber:latest docker ps docker exec -ti eb25daZ bash
docker build -t grabber:latest . <- point pas oublier docker rm --force grabber docker ps docker container ls -a docker container prune docker logs grabber docker run -dit --name grabber grabber docker inspect grabber docker exec -ti grabber bash mettreAdresseIP
compose.yml services: grabber: build: . depends_on : db ports: -"8080:80" db: image: postgres:18 environment: POSTGRES_USER: gb POSTGRES_DB: gbdb
- [Modif dans app.py] 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)
pour remplacer sqlite par postgres (postsql)