diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..518406a1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM ubuntu as compiler + +RUN apt update + +# Install tzdata without being interactive +RUN ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata + +# Tools to compile: +RUN apt install -y build-essential cmake clang-format shellcheck curl + +COPY . /compile +WORKDIR /compile + +RUN make configure +RUN make compile + +FROM ubuntu +COPY --from=compiler /compile/build/dist/bin/jsonschema /usr/local/bin/jsonschema +WORKDIR /schema +ENTRYPOINT ["/usr/local/bin/jsonschema"] \ No newline at end of file diff --git a/README.markdown b/README.markdown index edb2edfe..54039f7a 100644 --- a/README.markdown +++ b/README.markdown @@ -72,6 +72,22 @@ latest pre-built binaries, which you can run as follows: /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/intelligence-ai/jsonschema/main/install -H "Cache-Control: no-cache, no-store, must-revalidate")" ``` +### From Dockerfile + +You can compile the software inside a container and run it with Docker: + +```sh +docker build -t jsonschema . +``` + +Then you can validate files by mounting them in the `/schema` folder: + +```sh +docker run -it -v "$PWD:/schema" jsonschema lint --verbose myschema.json +# Optionally add to your .alias (or similar) file: +# alias jsonschema="docker run -it -v \"$PWD:/schema\" jsonschema" +``` + ### Building from source ```sh