cdent / gabbi

Declarative HTTP Testing for Python and anything else
http://gabbi.readthedocs.org/
Other
148 stars 34 forks source link

Consider to provide docker image for gabbi-run #284

Closed avkonst closed 2 years ago

avkonst commented 3 years ago

Great tool. I keep using it more and more. Currently I build my own docker image with gabbi-run. It would be great if there was an official gabbi-run image provided.

Here is the sample Dockerfile:

FROM python:3.8-alpine

ARG GABBI_VERSION
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN echo ${GABBI_VERSION}
RUN pip install gabbi==${GABBI_VERSION}
ENTRYPOINT ["gabbi-run"]

Here is how to build it:

export GABBI_VERSION=2.0.3
docker build . --build-arg GABBI_VERSION=$GABBI_VERSION -t gabbi:$GABBI_VERSION
cdent commented 3 years ago

Thanks, this is a good idea. And thanks for providing the working sample.

What's probably the best thing to do here is integrate this with the CI so that a new image is built each time a release is tagged. I'll need to do some investigation to make that happen.

cdent commented 3 years ago

I've started experimenting with this and I have it basically working, but the interaction is a bit weird.

If you provide the yaml on stdin it can work fine:

$ docker  run -i gabbi:latest < /tmp/tests.yaml 
... ✓ gabbi-runner.input_get

----------------------------------------------------------------------
Ran 1 test in 0.085s

OK

But if you are used to providing filenames on the arg list it can be a bit more complicated. Do you always use STDIN?

avkonst commented 3 years ago

You need to mount the directory with test files. (Also suggest to add --rm flag to let docker cleanup the containers when finished).

docker  run -it --rm -v /tmp:/proj gabbi:latest -- /proj/tests.yaml 

If your test files are in the current directory, it can be mounted to a working directory in the container:

docker  run -it --rm -v ./:/wdir -w /wdir gabbi:latest -- tests.yaml 
cdent commented 3 years ago

That's kind of what I assumed but it feels...clumsy.

I guess if it was scripted it would be no big deal. I'll keep playing with it. Should have something within a few days.

avkonst commented 3 years ago

Be aware that deployment with docker is not for the purpose to replace native installation on a development host. It is for the purpose to automate CI tests and simplify trials of a tool without asking people to install python, etc... We use gitlab pipelines. Each job in the pipeline needs a container to run. If we use gabbi for a test job, it has to be an image with gabbi inside of it.

cdent commented 3 years ago

Just so you know, I haven't forgotten about this.

cdent commented 2 years ago

https://hub.docker.com/repository/docker/cdent/gabbi