Skip to content

Commit

Permalink
Add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-ignatov committed Jul 8, 2024
1 parent a15bf2a commit cf7d150
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit cf7d150

Please sign in to comment.