Skip to content

Commit

Permalink
Add a Docker artifact (#61)
Browse files Browse the repository at this point in the history
In case this might be interesting to anyone, this PR adds a multistage
Dockerfile based on the latest Ubuntu, compiles the project using the
`Makefile` and copies the resulting binary to a new, clean, image.
  • Loading branch information
alombarte authored Jun 7, 2024
1 parent de666bf commit 7034512
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
16 changes: 16 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7034512

Please sign in to comment.