canonical / chisel-releases

36 stars 51 forks source link

Slicing libpq5 required in python to access a posgres database #261

Closed gregory-schiano closed 5 months ago

gregory-schiano commented 5 months ago

Proposed changes

Slicing libpq5 used to access posgres databases

Related issues/PRs

N/A

Forward porting

N/A

Testing

Start a docker container running ubuntu-22.04 while being in this repository folder and a postgres database

docker run --name postgres -e POSTGRES_PASSWORD=secret -d postgres:15
#Get this container IP address using docker inspect postgres and note it
docker run -d --name flask -v $(pwd):/home/chisel ubuntu:22.04 sleep 3600
docker exec -ti flask bash
apt update && apt install -y golang-1.22 ca-certificates curl python3-venv git
update-alternatives --install /usr/bin/go go /usr/lib/go-1.22/bin/go 0
go install github.com/canonical/chisel/cmd/chisel@latest
/root/go/bin/chisel cut --release /home/chisel/ --root / libpq5_libs
cd /home
git clone https://github.com/canonical/sample-flask.git
cd sample-flask
git checkout feat-database
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
#Use the IP address noted earlier here
POSTGRESQL_DB_CONNECT_STRING="postgresql://postgres:secret@172.17.0.3:5432/postgres" flask run -p 8000 &
#Press enter, you'll have some output from the previous command put in background
watch -n 2 curl localhost:8000
#You'll see the visitor counter incrementing

Checklist

Additional Context

N/A

github-actions[bot] commented 5 months ago

Diff of dependencies: None found.


cjdcordeiro commented 5 months ago

@gregory-schiano I've merged this since it is time critical. We do have a rule though that all slices must be forward ported. So, whenever you have the time, can you please open a similar PR against the 24.04 branch?

gregory-schiano commented 5 months ago

@gregory-schiano I've merged this since it is time critical. We do have a rule though that all slices must be forward ported. So, whenever you have the time, can you please open a similar PR against the 24.04 branch?

The slice already exists in ubuntu-24.04

cjdcordeiro commented 5 months ago

Even better then :) thanks