orange-beach-75711
09/05/2020, 6:34 AMFROM python:3.7.7-slim
RUN apt-get update \
&& apt-get install -y \
curl \
cmake \
build-essential \
&& apt-get clean
EXPOSE 3000
WORKDIR /app
RUN curl -L -o ./pants <https://pantsbuild.github.io/setup/pants> \
&& chmod +x ./pants
# Copy src dir and pants config files
COPY ./src /app/src/
COPY BUILD /app/
COPY pants_docker.toml /app/pants.toml
COPY requirements.txt /app/
COPY ./dist /app/dist/
RUN ./pants --version
RUN ./pants binary src/nabu/services/api:server
CMD ./dist/server.pex nabu.services.api.wsgi:app -c src/nabu/services/api/gunicorn.conf.py
hundreds-breakfast-49010
09/07/2020, 11:00 PMhundreds-breakfast-49010
09/07/2020, 11:07 PMhundreds-breakfast-49010
09/07/2020, 11:08 PMhundreds-breakfast-49010
09/07/2020, 11:09 PMhundreds-breakfast-49010
09/07/2020, 11:16 PMhundreds-father-404
09/08/2020, 4:02 PMIs there a way to enable ‘live reloading’ while debugging/code changes?I agree this would be useful. We have an experimental option
--loop
, but it does not work well right. We’ve been working on the upcoming 2.0 release, and as part of that, we’re putting polish on lots of pieces relevant to getting --loop
working, such as improving the Pants daemon (pantsd)
https://github.com/pantsbuild/pants/issues/9462 tracks this feature. Could you please comment that you’d appreciate this feature and how you’d want to use it (e.g. for repl
, for test
, for something else?)? https://github.com/pantsbuild/pants/issues/9462hundreds-father-404
09/08/2020, 4:18 PMAre there any best practices for using pants to generate & run pex binaries inside Dockerfiles?Interesting. So Pants stores its caches (by default) in
~/.cache/pants/lmdb_store
and ~/.cache/pants/named_caches
. The problem is that you’d need that to be persisted across runs.
In our CI, we use volumes, along with setting some image args so that we can call WORKDIR
. See https://github.com/pantsbuild/pants/blob/master/build-support/docker/travis_ci/Dockerfile, then https://github.com/pantsbuild/pants/blob/bc16088727e63739a648605bc996b81a65a513d1/.travis.yml#L78-L84 for where we build and run the image. https://dev.to/jibinliu/how-to-persist-data-in-docker-container-2m72 is maybe useful background too on Docker volumes
Would something like this work?happy-kitchen-89482
09/08/2020, 6:41 PMorange-beach-75711
09/11/2020, 1:57 AMorange-beach-75711
09/11/2020, 2:19 AMorange-beach-75711
09/11/2020, 2:20 AMlong-term, we would probably like to have pants itself create a docker image as one of many types of build artifacts that pants can produceThis makes a lot of sense! Is there an issue I can upvote for this 🙂.
hundreds-father-404
09/11/2020, 2:20 AMorange-beach-75711
09/11/2020, 2:22 AMorange-beach-75711
09/11/2020, 2:26 AMwhat sort of workflow are you imagining with "live reloading"? pants has the functionality to run a daemon (pantsd) that keeps a bunch of pants state in memory and allows subsequent pants commands to run more quickly
I agree this would be useful. We have an experimental optionGreat! Would love to see this make it to a stable release. There are a few workflows but the most common one for us is manual testing of APIs on a gRPC or a Flask server. Debugging/development is much faster if the locally running server reloads when a source file changes., but it does not work well right. We’ve been working on the upcoming 2.0 release, and as part of that, we’re putting polish on lots of pieces relevant to getting--loop
working, such as improving the Pants daemon (pantsd)--loop
https://github.com/pantsbuild/pants/issues/9462 tracks this feature. Could you please comment that you’d appreciate this feature and how you’d want to use it (e.g. forGreat, will do!, forrepl
, for something else?)?test
hundreds-father-404
09/11/2020, 2:28 AMIs there a suggested workaround for this right now?Unfortunately, not yet. You’d have to use 1.30.0rc0 and the v1 implementation of Python. You can mix and match the v1 and v2 implementations, like use v2 for the Python formatters and linters, but v1 for
test
, run
, binary
, and repl
. The v2 linters and formatters wouldn’t have access to the code genned files, but generally that should be fine afaictorange-beach-75711
09/11/2020, 2:28 AMorange-beach-75711
09/11/2020, 2:30 AMIn our CI, we use volumes, along with setting some image args so that we can callI'll definitely give this suggestion a try. I've used volumes before for something similar (ex. hot reloading inside a docker container as a source file on the host changes) . My only concern here is that there are some libraries (ex. bcrypt) that need to be built on the same platform as the runtime platform.. See https://github.com/pantsbuild/pants/blob/master/build-support/docker/travis_ci/Dockerfile, then https://github.com/pantsbuild/pants/blob/bc16088727e63739a648605bc996b81a65a513d1/.travis.yml#L78-L84 for where we build and run the image. https://dev.to/jibinliu/how-to-persist-data-in-docker-container-2m72 is maybe useful background too on Docker volumesWORKDIR
hundreds-father-404
09/11/2020, 2:31 AM[GLOBAL]
v1 = true
v2 = true
backend_packages = ["pants.backend.python"]
backend_packages2 = ["pants.backend.python.lint.isort", ...]
Pants will use v2 for fmt
and lint
, but v1 for everything elseorange-beach-75711
09/11/2020, 2:33 AMpython_grpcio_library
target mentioned here - https://v1.pantsbuild.org/grpcio_gen.html right?hundreds-father-404
09/11/2020, 2:34 AMbackend_packages = ["pants.backend.python"]
. In v1, we activated all backends by default. (Which was a bad idea, but difficult to deprecate). The snippet I had given would override the default.
You can run ./pants target-types
to confirm that python_grpcio_library
shows uporange-beach-75711
09/11/2020, 6:36 AMminiature-lamp-45970
09/12/2020, 6:47 PMhundreds-father-404
09/12/2020, 6:56 PMhundreds-father-404
09/12/2020, 7:04 PMminiature-lamp-45970
09/12/2020, 7:09 PMhundreds-father-404
09/12/2020, 7:14 PM