-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
96 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.DS_Store | ||
*.log | ||
**/.env | ||
.git | ||
.gitignore | ||
*.log | ||
**/node_modules | ||
**/npm-debug.log | ||
Dockerfile | ||
.dockerignore | ||
**/dist | ||
**/eslint.config.mjs | ||
**/.prettierrc.json | ||
**/vitest.config.js | ||
**/vitest.workspace.js | ||
**/*.md | ||
.github | ||
**/docs | ||
.vscode |
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,32 @@ | ||
# Node build image | ||
FROM node:22.12.0-bookworm AS builder | ||
# Install Ubuntu packages + dumb-init | ||
RUN apt-get update && apt-get install -y --no-install-recommends dumb-init | ||
# Set working directory | ||
WORKDIR /app | ||
# Copy package.json and package-lock.json | ||
COPY ./package*.json . | ||
# Install NPM dependencies | ||
RUN npm install | ||
# Copy source files | ||
COPY . . | ||
# Build the app (TS > JS + treeshake + bundle + minify with Esbuild) | ||
RUN npm run build | ||
|
||
# Production image | ||
FROM node:22.12.0-bookworm-slim AS production | ||
# Install ca-certificates | ||
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/* | ||
# Set Node.js environment to production | ||
ENV NODE_ENV=production | ||
# Copy dumb-init from builder | ||
COPY --from=builder /usr/bin/dumb-init /usr/bin/dumb-init | ||
# Do not run as root, create a new user | ||
USER node | ||
WORKDIR /app | ||
# Copy bundled app with source map from builder container | ||
COPY --chown=node:node --from=builder /app/dist . | ||
# Set environment variable as an example | ||
ENV CONTAINERIZED=true | ||
# Run the app | ||
CMD ["sh", "-c", "dumb-init node index.mjs"] |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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