Skip to content

Commit

Permalink
Fixed Dockerfile configuration to use esmodules instead of common js
Browse files Browse the repository at this point in the history
CommonJS seems to be failing with

```
emmett_api    | SyntaxError: await is only valid in async functions and the top level bodies of modules
emmett_api    |     at wrapSafe (node:internal/modules/cjs/loader:1378:20)
emmett_api    |     at Module._compile (node:internal/modules/cjs/loader:1428:41)
emmett_api    |     at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
emmett_api    |     at Module.load (node:internal/modules/cjs/loader:1288:32)
emmett_api    |     at Module._load (node:internal/modules/cjs/loader:1104:12)
emmett_api    |     at Module.require (node:internal/modules/cjs/loader:1311:19)
emmett_api    |     at require (node:internal/modules/helpers:179:18)
emmett_api    |     at Object.<anonymous> (/app/dist/index.cjs:1:644)
emmett_api    |     at Module._compile (node:internal/modules/cjs/loader:1469:14)
emmett_api    |     at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
emmett_api    |
emmett_api    | Node.js v20.18.0
```
  • Loading branch information
oskardudycz committed Oct 11, 2024
1 parent 6dfb21b commit 84dd2ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion samples/webApi/expressjs-with-esdb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ WORKDIR /app

# Copy published in previous stage binaries
# from the `builder` image
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules

Expand All @@ -50,4 +51,4 @@ EXPOSE 3000

# sets entry point command to automatically
# run application on `docker run`
ENTRYPOINT ["node", "./dist/index.cjs"]
ENTRYPOINT ["node", "./dist/index.js"]
3 changes: 2 additions & 1 deletion samples/webApi/expressjs-with-postgresql/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ WORKDIR /app

# Copy published in previous stage binaries
# from the `builder` image
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules

Expand All @@ -50,4 +51,4 @@ EXPOSE 3000

# sets entry point command to automatically
# run application on `docker run`
ENTRYPOINT ["node", "./dist/index.cjs"]
ENTRYPOINT ["node", "./dist/index.js"]

0 comments on commit 84dd2ae

Please sign in to comment.