Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dockerfile
node_modules
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

on:
push:
tags:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To facilitate testing this workflow in GitHub Actions, this used to listen to pushes on a branch. Before opening the PR, I updated it specifically to listen to pushes on tags.

- "*"

jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- name: Checkout commit and fetch tag history
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step looks a little over-engineered, but was used because it was the recommended approach to annotating the container image to be published .

with:
images: vercel/cosmosdb-server
tag-semver: |
{{version}}
{{major}}.{{minor}}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:12-slim
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Dockerfile was heavily influenced by the existing WIP changes in master...ridhoq:docker.


WORKDIR /app

COPY package.json yarn.lock ./

RUN yarn install --production=false --frozen-lockfile

COPY . .

RUN yarn run build

ENTRYPOINT [ "node", "lib/cli.js" ]
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,17 @@ export default (opts?: ServerOptions) => {
}
});

const gracefulShutdown = () => {
console.debug("Attempting a graceful shutdown...");

server.close(() => {
console.debug("Existing connections closed. Exiting...");
process.exit(0);
});
};

process.on('SIGINT', gracefulShutdown);
process.on('SIGTERM', gracefulShutdown);

return server;
};