-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The path aliases and imports without extensions were giving issues after typescript compilation, leading to a situation where devleopment works fine but production crashes. So I chose here to just run the same way in prod as in development, namely using tsx. The alternative was doing bundling with esbuild for prod. But I don't see an issue or big disadvantage for us with using tsx in prod and the advantage is simplicity and debuggability and least chance of discrepancies between development and prod.
- Loading branch information
Francis Duvivier
committed
Dec 4, 2024
1 parent
9dbf70c
commit bde959a
Showing
7 changed files
with
73 additions
and
59 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
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,29 +1,23 @@ | ||
# Build Stage | ||
FROM node:22-bookworm-slim AS build | ||
|
||
WORKDIR /home/node/app | ||
|
||
COPY package*.json ./ | ||
RUN npm install | ||
COPY . . | ||
RUN npm run build | ||
|
||
# Prod stage | ||
FROM node:22-bookworm-slim | ||
|
||
WORKDIR /home/node/app | ||
ENV NODE_ENV=production | ||
|
||
# Copy only needed files | ||
COPY --chown=node:node --from=build /home/node/app/dist ./dist | ||
COPY --chown=node:node --from=build /home/node/app/public ./public | ||
COPY --chown=node:node --from=build /home/node/app/package*.json ./ | ||
COPY --chown=node:node ./package*.json . | ||
|
||
RUN npm ci --only=production --ignore-scripts | ||
|
||
COPY process.json . | ||
COPY --chown=node:node process.json . | ||
RUN mkdir -p /home/node/.pm2 /home/node/app/logs /home/node/app/pids && chown -R node:node /home/node/.pm2 /home/node/app/logs | ||
|
||
# db-migrate stuff | ||
COPY --chown=node:node migrations ./migrations | ||
COPY --chown=node:node database.json . | ||
|
||
COPY --chown=node:node ./public ./public | ||
COPY --chown=node:node ./src ./src | ||
|
||
USER node | ||
EXPOSE 8081 | ||
CMD ["./node_modules/pm2/bin/pm2-runtime", "process.json"] |
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 |
---|---|---|
|
@@ -43,4 +43,4 @@ volumes: | |
networks: | ||
badgehub_network: | ||
name: badgehub_network | ||
external: true | ||
external: true |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.