A cat monitoring app (mostly a docker tutorial)
Run only the postgres database using docker.
docker run --name postgresql -e POSTGRES_USER=guaiguai -e POSTGRES_PASSWORD=mdp -p 5432:5432 -v ./data:/var/lib/postgresql/data -d postgres Check the image.
docker imagesCheck the container.
docker psTo get a shell inside the container.
docker exec -it postgresql bashTo connect to the database from the host.
psql -h localhost -p 5432 -U guaiguai -d postgresin the scripts directory are scripts to add data to the database. First set up the environment.
cd scripts/
python -m venv .venv
source .venv/bin/activate
poetry install --no-rootThen run the fill script.
python fill_db.pyCheck that it worked.
python print_db.pyFirst set-up the environment.
cd catmonitor/
python -m venv .venv
source .venv/bin/activate
poetry install
cd ..With the catmonitor/.venv activated and from the root of the project.
streamlit run catmonitor/catmonitor/catdisplay.pyFrom the root of the project.
docker build -t catmonitor_img -f catmonitor/Dockerfile . &&if docker ps -a|grep -q catmonitor; then docker rm -f catmonitor; fi &&docker run --name catmonitor -p 8501:8501 catmonitor_imgSee below.
First set-up the environment.
cd catapi/
python -m venv .venv
source .venv/bin/activate
poetry install
cd ..With the catapi/.venv activated and from the root of the project.
uvicorn api:app --app-dir=catapi/catapi/same.
See below.
In a terminal.
curl -X POST 127.0.0.1:8000/masse -H "Content-Type:application/json" --data '{"name": "Guaiguai"}'curl 127.0.0.1:8000/ -H "Content-Type:application/json"From the root of the project.
docker compose up --build -dTo get the logs.
docker compose logs -fFor a specific service.
docker compose logs -f catapiThen to clean up.
docker compose down