pmcelhaney / counterfact

OpenAPI / Swagger to TypeScript generator and mock server
MIT License
104 stars 13 forks source link

Publish official Docker image #920

Open mjpowersjr opened 5 months ago

mjpowersjr commented 5 months ago

I'm using counterfact while writing integration tests with Jest. Before my tests begin, I launch a few local Docker containers using the testcontainers project. I wrote a small Dockerfile to run counterfact inside a container, but I need to build the image as part of my test setup. It would be nice if there was an official image I could use, and skip the build step.

There is one related issue that I hit while running counterfact inside a container. Initially I wanted to just bind mount my api schema, and existing generated counterfact code into the container (as a read-only mount). This didn't work, because counterfact was trying to write to the .cache directory from within the container. I believe allowing customization of the .cache directory would help.

Dockerfile

FROM node:20-alpine

RUN mkdir /app

RUN npm add -g counterfact

USER node
WORKDIR /app

ENTRYPOINT [ "counterfact" ]
pmcelhaney commented 5 months ago

Thanks for the suggestion. I'll add the Docker image. (Or if you open a pull request, I'll gladly merge it. :))

By "customization of the .cache directory", do you mean a CLI flag like --cache /somewhere/out/of/the/way? I'm happy to add that.

pmcelhaney commented 5 months ago

Also, would it suffice to drop the Dockerfile into the root of the project or do you need it to be published to some repository?

pmcelhaney commented 4 months ago

@mjpowersjr checking in to see if you have any other thoughts. I saw you forked the repo and had started to make some improvements. I would love the help!