diff --git a/.dockerignore b/.dockerignore index 3c67b0a1b..80e59ef52 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,2 @@ tests -.git node_modules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..68f9fc032 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +ARG BASE_IMAGE=denoland/deno:2.0.1 +FROM ${BASE_IMAGE} AS build +WORKDIR /src + +RUN apt-get update && \ + apt-get install -y git jq && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +ADD . . +RUN export VERSION=`git -C . -c safe.directory=* describe --tags --always` && \ + jq -r ".version|=\"$VERSION\"" bids-validator/deno.json > ._deno.json + +WORKDIR /src/bids-validator +RUN deno cache ./bids-validator-deno +RUN ./build.ts + +FROM ${BASE_IMAGE} AS base +WORKDIR /src +COPY . . +COPY --from=build /src/._deno.json /src/bids-validator/deno.json +WORKDIR /src/bids-validator +RUN deno cache ./bids-validator-deno +ENTRYPOINT ["./bids-validator-deno"] + +FROM ${BASE_IMAGE} AS min +WORKDIR /src +COPY --from=build /src/bids-validator/dist/validator/* . + +ENTRYPOINT ["deno", "-A", "./bids-validator.js"] diff --git a/README.md b/README.md index c769d7cf5..e4b1b1590 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ ## Quickstart -This repository currently houses 4 packages: +This repository houses 4 packages: 1. [./bids-validator](./bids-validator)The current deno based bids-validator cli and library 2. [./web](./web)The current web based validator 3. [./legacy/bids-validator](legacy/bids-validator)The legacy node validator diff --git a/bids-validator/Dockerfile b/bids-validator/Dockerfile deleted file mode 100644 index 1fde2e02b..000000000 --- a/bids-validator/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -ARG BASE_IMAGE=denoland/deno:2.0.1 -FROM ${BASE_IMAGE} AS base -WORKDIR /src - -RUN apt-get update && \ - apt-get install -y git && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -COPY . . -RUN deno cache ./bids-validator-deno -RUN ./build.ts - -ENTRYPOINT ["./bids-validator-deno"] - -FROM ${BASE_IMAGE} AS min -WORKDIR /src -COPY --from=base /src/dist/validator/* . - -ENTRYPOINT ["deno", "-A", "./bids-validator.js"] diff --git a/bids-validator/src/version.ts b/bids-validator/src/version.ts index a54acf381..7c65b06ec 100644 --- a/bids-validator/src/version.ts +++ b/bids-validator/src/version.ts @@ -33,12 +33,17 @@ export async function getVersion(): Promise { async function getLocalVersion(path: string): Promise { // safe.directory setting so we could still operate from another user - const command = new Deno.Command("git", { - args: ['-C', path, '-c', 'safe.directory=*', 'describe', '--tags', '--always'], - }) - const { success, stdout } = await command.output(); - const description = new TextDecoder().decode(stdout).trim() - return description + try { + const command = new Deno.Command("git", { + args: ['-C', path, '-c', 'safe.directory=*', 'describe', '--tags', '--always'], + }) + const { success, stdout } = await command.output(); + console.log(success) + const description = new TextDecoder().decode(stdout).trim() + return description + } catch(err) { + return "" + } } function getArchiveVersion(): string | undefined {