bright-church-87196
05/01/2024, 12:39 PMbright-church-87196
05/01/2024, 12:42 PMFROM --platform="linux/amd64" python:3.11-slim
COPY src.python.backend/main.pex /bin/main
ENTRYPOINT ["/bin/main"]
Compose
version: "3"
services:
backend:
container_name: xxxx-backend
restart: unless-stopped
image: xxxx-backend:latest
ports:
- "8000:8000"
env_file:
- .env.dev
environment:
- UVICORN_RELOAD=true
BUILDs
docker_environment(
name="python_base",
image="python:3.11-slim",
platform="linux_x86_64",
python_bootstrap_search_path=[""],
)
docker_image(
name="xxxx-backend",
source="Dockerfile",
restartable=True
)
python_sources(
name="backend",
restartable=True,
)
pex_binary(
name="main",
entry_point="main.py",
dependencies=[":backend"],
include_tools=True,
environment="linux_docker", (references the env previously built)
restartable=True,
)
With this setup I can run my image normally, but i’ve tried multiple different solutions I’ve seen here and can’t get hot reload workingbright-church-87196
05/01/2024, 12:43 PMlemon-eye-70471
05/01/2024, 4:00 PM'loose'
so that the PEX is an unpacked source folder then volume mapping the source code into the root of pex folder. So for your setup it might look like:
BUILD
pex_binary(
name="main",
entry_point="main.py",
dependencies=[":backend"],
include_tools=True,
environment="linux_docker", (references the env previously built)
restartable=True,
layout='loose'
)
compose
version: "3"
services:
backend:
container_name: xxxx-backend
restart: unless-stopped
image: xxxx-backend:latest
ports:
- "8000:8000"
env_file:
- .env.dev
environment:
- UVICORN_RELOAD=true
volumes:
- src/python/backend:/bin/main
bright-church-87196
05/02/2024, 2:19 PMlemon-eye-70471
05/02/2024, 2:21 PMbright-church-87196
05/02/2024, 2:24 PMdocker_environment(
name="python_base",
image="python:3.11-slim",
platform="linux_x86_64",
python_bootstrap_search_path=[""],
)
this envlemon-eye-70471
05/02/2024, 2:30 PMpants run
. I think in your case it'd be:
docker compose run --rm --service-ports backend /bin/main