Skip to content

Commit

Permalink
fix: docker prod build
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsondavid committed Oct 11, 2024
1 parent d711f62 commit 071dfb4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM node:20-alpine3.19
WORKDIR /app
COPY package*.json .
FROM node:20-alpine3.19 as base

FROM base as builder
WORKDIR /build
COPY package*.json .npmrc ./
RUN npm ci --prefer-offline --no-audit
COPY . .
RUN npm run build
RUN npm prune --include=prod
RUN npm run build && npm prune --production

FROM base
WORKDIR /app
COPY --from=builder /build ./
ENTRYPOINT ["node", "--enable-source-maps", "dist/main.js"]
2 changes: 1 addition & 1 deletion src/main.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ app.use("/assets/*", async (c, next) => {
app.use("*", serveStatic({ root: "./dist/static" }));
app.notFound(() => app.request("/"));

const server = serve({ fetch: app.fetch, port: 3000 }, ({ port }) => {
const server = serve({ fetch: app.fetch, port: Number(process.env.PORT) || 3000 }, ({ port }) => {
console.log(`server started on http://localhost:${port}/`);
});
process.on("SIGINT", () => {
Expand Down

0 comments on commit 071dfb4

Please sign in to comment.