From cf7d15024967e5e03e57f63b3ec8eeced1fdae3e Mon Sep 17 00:00:00 2001 From: Vladimir Ignatov Date: Mon, 8 Jul 2024 11:53:10 -0400 Subject: [PATCH] Add dockerfile --- Dockerfile | 24 ++++++++++++++++++++++++ README.md | 11 +++++++++++ src/index.ts | 6 +++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9b16813 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM node:20-alpine + +# Defaults to 0 for random OS-allocated port but here we need a predictable fixed value to expose +ENV PORT=80 + +# Please provide your own secret if you deploy somewhere! +ENV SECRET="JWT signing secret" + +# Let the app know it is running in container +ENV CONTAINER=true + +RUN mkdir /app +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm i + +# Build +COPY . . +RUN npm run build:app + +EXPOSE 80 + +# Command to run the application +CMD ["/app/node_modules/.bin/ts-node", "--transpile-only", "./src/index.ts"] diff --git a/README.md b/README.md index 2990048..904e3ee 100644 --- a/README.md +++ b/README.md @@ -118,3 +118,14 @@ dates equal if they represent the same year, month, and day, ignoring the time p can also be loosely specified as `YYYY` or `YYYY-MM`. This means that, for example, we would match all of the following dates as equal: `2020`, `2020-01`, `2020-01-01`, `2020-01-01T10:12:34`. + +## Using Docker +This project also comes with a Docker file which makes it easy to run it anywhere. +To build the image run: +``` +docker build --tag=bulk-match-provider . +``` +And to run it on port `8080` you can do: +``` +docker run -it -p 8080:80 --rm bulk-match-provider +``` diff --git a/src/index.ts b/src/index.ts index 739ffb5..e1ed8f4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -131,7 +131,11 @@ async function main(): Promise<{ // istanbul ignore next if (require.main === module) { - main().then(({ address }) => console.log(`Server listening at ${address}`)); + main().then(({ address }) => { + if (!process.env.CONTAINER) { + console.log(`Server listening at ${address}`) + } + }); } export default main;