Skip to content

Commit

Permalink
Move dockerfile to base. Deno cli now handles git not existing.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwblair committed Oct 24, 2024
1 parent 5f75b1e commit 6923b6f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 28 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
tests
.git
node_modules
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 0 additions & 20 deletions bids-validator/Dockerfile

This file was deleted.

17 changes: 11 additions & 6 deletions bids-validator/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ export async function getVersion(): Promise<string> {

async function getLocalVersion(path: string): Promise<string> {
// 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 {
Expand Down

0 comments on commit 6923b6f

Please sign in to comment.