Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Handle SIGTERM for graceful shutdowns #16882

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cfc9fb7
Lint & handle sigterm
AndesKrrrrrrrrrrr Nov 14, 2024
540e92f
Remove eslint disable
AndesKrrrrrrrrrrr Nov 14, 2024
0134886
Add exit hooks to express-server
AndesKrrrrrrrrrrr Nov 22, 2024
535d43d
Add multiple exit hooks for next-server
AndesKrrrrrrrrrrr Nov 22, 2024
471c00b
Add build target
AndesKrrrrrrrrrrr Nov 22, 2024
1d8be1c
Dockerfile defaults and substitutions
AndesKrrrrrrrrrrr Nov 22, 2024
5b949e7
Dockerfile
AndesKrrrrrrrrrrr Nov 22, 2024
b14d1af
Add app/native node_modules to Docker ignores
AndesKrrrrrrrrrrr Nov 22, 2024
eeab818
Updated dockerignores
AndesKrrrrrrrrrrr Nov 22, 2024
991b0de
Add ls -lah, and ARG where needed
AndesKrrrrrrrrrrr Nov 22, 2024
75e19e6
Correct APP_{DIST_,}HOME in compose
AndesKrrrrrrrrrrr Nov 22, 2024
adeb8b1
Add APP_HOME and default APP_DIST_HOME to dist/$APP_HOME
AndesKrrrrrrrrrrr Nov 22, 2024
a5dfc56
Set ARG before use
AndesKrrrrrrrrrrr Nov 22, 2024
6419cc7
Commented and consolidated ARGs
AndesKrrrrrrrrrrr Nov 22, 2024
cade146
No exit 0
AndesKrrrrrrrrrrr Nov 22, 2024
bf72caf
Echo PWD
AndesKrrrrrrrrrrr Nov 22, 2024
bf2cd75
Remove APP_DIST_HOME in compose
AndesKrrrrrrrrrrr Nov 22, 2024
6271954
Cleanup and cache-bustless
AndesKrrrrrrrrrrr Nov 22, 2024
9f48811
Minimal-install packages in dist
AndesKrrrrrrrrrrr Nov 22, 2024
09d859d
Revert non-lib to main
AndesKrrrrrrrrrrr Nov 28, 2024
787f1dc
Remove temporary docker-compose
AndesKrrrrrrrrrrr Nov 28, 2024
75bdd29
Merge branch 'main' into fix/node-sigterm
AndesKrrrrrrrrrrr Nov 28, 2024
97d6a57
feat(core): Gracefully shutdown servers
eirikurn Nov 28, 2024
fdd8a2f
chore: nx format:write update dirty files
andes-it Nov 28, 2024
3fb51a3
Review feedback
eirikurn Nov 29, 2024
4974ecb
Merge branch 'main' into fix/node-sigterm
kodiakhq[bot] Nov 29, 2024
993bc52
Merge branch 'main' into fix/node-sigterm
kodiakhq[bot] Dec 1, 2024
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
Prev Previous commit
Next Next commit
Add ls -lah, and ARG where needed
  • Loading branch information
AndesKrrrrrrrrrrr committed Nov 22, 2024
commit 991b0de10239be397b5dd4c74e2c5892aee4f235
33 changes: 24 additions & 9 deletions scripts/ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -39,8 +39,8 @@ COPY libs libs/
COPY scripts scripts/
COPY tools tools/
RUN pwd && \
id && \
ls -lah && exit 0
ls -lah && \
exit 0


FROM src AS builder
@@ -51,6 +51,9 @@ ENV NODE_ENV=production
ENV NODE_OPTIONS="--max-old-space-size=8192"

RUN yarn run build ${APP} --prod
RUN pwd && \
ls -lah ./ && \
ls -lah ${APP_DIST_HOME}/main.js

# This is base image for containers that are to be deployed
FROM ${DOCKER_REGISTRY}/library/node:${NODE_IMAGE_TAG} AS output-base
@@ -74,40 +77,47 @@ USER runner

FROM output-base-with-pg AS output-express

ARG APP_DIST_HOME
COPY --from=builder /build/${APP_DIST_HOME} /webapp/

ARG GIT_BRANCH GIT_COMMIT_SHA GIT_REPOSITORY_URL
ENV GIT_BRANCH=${GIT_BRANCH} GIT_COMMIT_SHA=${GIT_COMMIT_SHA} GIT_REPOSITORY_URL=${GIT_REPOSITORY_URL}
ENV DD_GIT_BRANCH=${GIT_BRANCH} DD_GIT_COMMIT_SHA=${GIT_COMMIT_SHA} DD_GIT_REPOSITORY_URL=${GIT_REPOSITORY_URL}
LABEL branch=${GIT_BRANCH}
LABEL commit=${GIT_COMMIT_SHA}
RUN "ls -lah main.js"
RUN pwd && \
ls -lah ./ && \
ls -lah main.js
ENTRYPOINT [ "node", "--no-experimental-fetch", "main.js" ]

FROM output-base-with-pg AS output-next
ENV PORT=4200

# TODO: smallify
COPY --from=deps /build/node_modules /webapp/node_modules
ARG APP_HOME
ARG APP_DIST_HOME
COPY --from=builder /build/${APP_DIST_HOME} /webapp/

ARG GIT_BRANCH GIT_COMMIT_SHA GIT_REPOSITORY_URL
ENV GIT_BRANCH=${GIT_BRANCH} GIT_COMMIT_SHA=${GIT_COMMIT_SHA} GIT_REPOSITORY_URL=${GIT_REPOSITORY_URL}
ENV DD_GIT_BRANCH=${GIT_BRANCH} DD_GIT_COMMIT_SHA=${GIT_COMMIT_SHA} DD_GIT_REPOSITORY_URL=${GIT_REPOSITORY_URL}
LABEL branch=${GIT_BRANCH}
LABEL commit=${GIT_COMMIT_SHA}
RUN "ls -lah main.js"
RUN pwd && \
ls -lah ./ && \
ls -lah main.js
ENTRYPOINT [ "node", "main.js" ]

FROM ${DOCKER_REGISTRY}/nginx/nginx:1.21-alpine AS output-static
# hadolint ignore=DL3018
RUN apk add --no-cache bash nodejs

ARG APP
ARG APP_DIST_HOME
ENV APP=${APP}
ENV BASEPATH=/

# hadolint ignore=DL3018
RUN apk add --no-cache bash nodejs

COPY scripts/dockerfile-assets/nginx/* /etc/nginx/templates/
COPY scripts/dockerfile-assets/bash/extract-environment.sh /docker-entrypoint.d/
COPY scripts/dockerfile-assets/bash/extract-environment.js /docker-entrypoint.d/
@@ -126,6 +136,7 @@ FROM output-base AS output-jest
RUN npm install -g jest && \
echo 'module.exports = {};' > jest.config.js

ARG APP_DIST_HOME
COPY --from=builder /build/${APP_DIST_HOME} /webapp/

USER runner
@@ -173,7 +184,9 @@ ENV GIT_BRANCH=${GIT_BRANCH} GIT_COMMIT_SHA=${GIT_COMMIT_SHA} GIT_REPOSITORY_URL
ENV DD_GIT_BRANCH=${GIT_BRANCH} DD_GIT_COMMIT_SHA=${GIT_COMMIT_SHA} DD_GIT_REPOSITORY_URL=${GIT_REPOSITORY_URL}
LABEL branch=${GIT_BRANCH}
LABEL commit=${GIT_COMMIT_SHA}
RUN "ls -lah ./entrypoint.sh"
RUN pwd && \
ls -lah ./ && \
ls -lah ./entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]


@@ -197,7 +210,9 @@ ENV GIT_BRANCH=${GIT_BRANCH} GIT_COMMIT_SHA=${GIT_COMMIT_SHA} GIT_REPOSITORY_URL
ENV DD_GIT_BRANCH=${GIT_BRANCH} DD_GIT_COMMIT_SHA=${GIT_COMMIT_SHA} DD_GIT_REPOSITORY_URL=${GIT_REPOSITORY_URL}
LABEL branch=${GIT_BRANCH}
LABEL commit=${GIT_COMMIT_SHA}
RUN "ls -lah ./entrypoint.sh"
RUN pwd && \
ls -lah ./ && \
ls -lah ./entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]

FROM output-base AS output-native