curved-microphone-39455
01/16/2023, 3:55 PMgunicorn gevent psycogreen as requirements from poetry only when building my Docker Image. Currently I have added them in another poetry group which appear to include the dependencies when building the Docker image but I can't make it work with the pex_binary target, tested to specify the entry_point or the script in pex_binary but I keep getting error message.
Currently my build look like this
python_sources()
poetry_requirements(
name="poetry"
)
pex_binary(
name = "binary",
entry_point = "run.py",
layout = "packed",
execution_mode = "venv",
)
docker_image(
name = "img",
registries = ["<http://docker.io|docker.io>"],
repository = "repo/service",
image_tags = ["{build_args.RELEASE_VERSION}"]
)
My Dockerfile looks like this
FROM python:3.10-slim
ARG RELEASE_VERSION=latest
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3-dev \
libpq-dev \
&& apt-get clean autoclean \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -f /var/cache/apt/archives/*.deb \
COPY src.services.service/binary.pex /bin/app
ENV CONSUL [h=consul-svc,t=None]
EXPOSE 5001
CMD ["python", "/bin/app"]
This is working for development purpose, but we need gunicorn in production
I was reading this https://pex.readthedocs.io/en/v2.1.43/recipes.html#gunicorn-and-pex but I don't see how I can reproduce this through Pants!
Thanks 🙂aloof-appointment-30987
01/16/2023, 5:02 PMpex_binary target?
pex_binary(
name = "binary",
dependencies=[":poetry"],
entry_point = "run.py",
layout = "packed",
execution_mode = "venv",
)
I am not familiar with Gunicorn and Flask but this seems logical to me if the poetry config references the required dependencies. You may have to adjust the entry point according to the pex reference you included.curved-microphone-39455
01/16/2023, 5:15 PMpex_binary(
name="binary-deps",
entry_point = "gunicorn",
dependencies = ["src/services/service","src/services/service:poetry#gevent", "src/services/service:poetry#psycogreen"],
layout="packed",
include_sources=False,
include_tools=True,
)curved-microphone-39455
01/16/2023, 5:16 PMcurved-microphone-39455
01/16/2023, 5:16 PM