-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (32 loc) · 1.03 KB
/
Dockerfile
File metadata and controls
40 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
FROM node:20-alpine
RUN adduser -D -u 1001 ignite
WORKDIR /app
COPY package*.json ./
RUN if [ -f package-lock.json ]; then npm ci --only=production; \
elif [ -f package.json ]; then npm install --only=production; \
fi
COPY --chown=ignite:ignite . .
ARG ENTRY_FILE=index.js
ENV ENTRY_FILE=${ENTRY_FILE}
RUN printf '%s\n' \
'const entryFile = process.env.ENTRY_FILE || "index.js";' \
'const startTime = Date.now();' \
'' \
'async function run() {' \
' try {' \
' await import("/app/" + entryFile);' \
' } catch (err) {' \
' console.error(err);' \
' process.exit(1);' \
' }' \
'}' \
'' \
'run().finally(() => {' \
' const initTime = Date.now() - startTime;' \
' const mem = Math.round(process.memoryUsage().heapUsed / 1024 / 1024 * 100) / 100;' \
' process.stderr.write("IGNITE_INIT_TIME:" + initTime + "\\n");' \
' process.stderr.write("IGNITE_MEMORY_MB:" + mem + "\\n");' \
'});' \
> /entrypoint.mjs && chown ignite:ignite /entrypoint.mjs
USER ignite
CMD ["node", "/entrypoint.mjs"]