Is there a good way to start multiple applications...
# general
w
Is there a good way to start multiple applications in a monorepo without using the
--concurrent
flag?
b
we use docker compose and/or --concurrent; the bad thing about docker is that we lose hot reload
w
If i undestand correctly: For local development you use
pants package ...
and afterwards you just run your applications locally with docker (compose) ?
b
Pants packages into a pex, then packages into a docker image, then i start the docker image using a compose.yml BUILD
Copy code
python_sources(name = "lib")

pex_binary(
    name = "funds-service",
    args = ["funds.main:app"],
    dependencies = [
        ":lib",
        "3rdparty/py:reqs#psycopg",
        "3rdparty/py:reqs#greenlet",
    ],
    entry_point = "gunicorn",
    env = {
        "GUNICORN_CMD_ARGS": '-k uvicorn.workers.UvicornWorker -w 1 --forwarded-allow-ips="*" --access-logfile "-" --logger-class "libs.core.logger.GunicornLogger"',
        "PORT": "5001",
    },
    restartable = True,
)

docker_image(
    name = "funds",
    dependencies = [
        "src/docker/base:base",
    ],
    source = "Dockerfile",
)
Dockerfile
Copy code
FROM --platform=linux/arm64 local/base

# Copy pex files into the container
COPY src.py.apps.funds/funds-service.pex /bin/funds-service

# entrypoint
ENTRYPOINT ["/bin/funds-service"]
compose.yml
Copy code
funds:
    restart: always
    env_file:
      - .env.docker
    image: local/funds:latest
    ports:
      - '5001:5001'
    depends_on:
      kafka:
        condition: service_started
    logging:
      driver: 'json-file'
      options:
        max-size: '100m'
        max-file: '3'
w
what i do is just package into pex and run that, you could create a shell target for that probably.
w
All these approaches are viable, but still time consuming. Building a pex or docker image each time, is what i would like to avoid. Thats why i want to use
pants run ...
on the sources, but as soon as i need to start 2 applications in the monorepo, i have use the
--concurrent
flag which i want to avoid. Any ideas?