-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add graceful shutdown and health check url
- Loading branch information
Showing
5 changed files
with
70 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
FROM node:22-alpine AS build | ||
|
||
RUN apk add dumb-init | ||
|
||
WORKDIR /home/node | ||
|
||
COPY . . | ||
RUN yarn install --frozen-lockfile && yarn build | ||
|
||
RUN yarn install --frozen-lockfile | ||
RUN yarn build | ||
|
||
FROM node:22-alpine | ||
|
||
ENV NODE_ENV production | ||
|
||
RUN apk update && apk upgrade --no-cache | ||
COPY --from=build /usr/bin/dumb-init /usr/bin/dumb-init | ||
|
||
RUN addgroup --gid 3000 --system juffgroup \ | ||
&& adduser --uid 2000 --system --ingroup juffgroup juffuser | ||
RUN apk update && \ | ||
apk upgrade --no-cache && \ | ||
addgroup --gid 3000 --system juffgroup && \ | ||
adduser --uid 2000 --system --ingroup juffgroup juffuser && \ | ||
mkdir /home/juffuser/express-graphql-example/ | ||
|
||
USER 2000:3000 | ||
|
||
RUN mkdir /home/juffuser/express-graphql-example/ | ||
WORKDIR /home/juffuser/express-graphql-example/ | ||
|
||
COPY --from=build /home/node/dist ./dist | ||
COPY --from=build /home/node/package.json /home/node/yarn.lock ./ | ||
RUN yarn install --frozen-lockfile --production | ||
COPY --from=build /home/node/node-modules ./node-modules | ||
|
||
EXPOSE 3010 | ||
|
||
CMD [ "node", "dist/index.js" ] | ||
CMD [ "dumb-init", "node", "dist/index.js" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import express from 'express'; | ||
import { createHandler } from 'graphql-http/lib/use/express'; | ||
import responseTime from './middlewares/reponseTime'; | ||
import cors from './middlewares/cors'; | ||
import context from './context'; | ||
import schema from './schema'; | ||
|
||
const app = express(); | ||
|
||
app.disable('x-powered-by'); | ||
app.use(express.json()); | ||
app.use(express.urlencoded({ extended: true })); | ||
app.use(responseTime); | ||
app.use(cors); | ||
|
||
app.all('/graphql', createHandler({ | ||
schema, | ||
context: context as any, | ||
})); | ||
|
||
export default app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,6 +323,13 @@ | |
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.1.tgz#de633db3ec2ef6a3c89e2f19038063e8a122e2c2" | ||
integrity sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q== | ||
|
||
"@godaddy/terminus@^4.12.1": | ||
version "4.12.1" | ||
resolved "https://registry.yarnpkg.com/@godaddy/terminus/-/terminus-4.12.1.tgz#c4fdc280a4ac9655d4734250e22299a4ad46c54c" | ||
integrity sha512-Tm+wVu1/V37uZXcT7xOhzdpFoovQReErff8x3y82k6YyWa1gzxWBjTyrx4G2enjEqoXPnUUmJ3MOmwH+TiP6Sw== | ||
dependencies: | ||
stoppable "^1.1.0" | ||
|
||
"@humanwhocodes/config-array@^0.13.0": | ||
version "0.13.0" | ||
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.13.0.tgz#fb907624df3256d04b9aa2df50d7aa97ec648748" | ||
|
@@ -3445,6 +3452,11 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" | ||
integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== | ||
|
||
stoppable@^1.1.0: | ||
version "1.1.0" | ||
resolved "https://registry.yarnpkg.com/stoppable/-/stoppable-1.1.0.tgz#32da568e83ea488b08e4d7ea2c3bcc9d75015d5b" | ||
integrity sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw== | ||
|
||
string-length@^4.0.1: | ||
version "4.0.2" | ||
resolved "https://registry.yarnpkg.com/string-length/-/string-length-4.0.2.tgz#a8a8dc7bd5c1a82b9b3c8b87e125f66871b6e57a" | ||
|