-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.tini
43 lines (36 loc) · 1.01 KB
/
Dockerfile.tini
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
41
42
43
############## Build stage
FROM node:18.16.0-bookworm-slim as build
# Set the working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json /app/
# Install dependencies
RUN npm ci --no-audit
# Copy the rest of the source code
COPY . .
# Build the application
RUN npm run build
# keep only production deps
RUN npm prune --omit=dev
############## Build the final production image
FROM node:18.16.0-bookworm-slim
# Set env vars
ENV NODE_ENV production
# Use tini
RUN apt-get update && apt-get install -y tini
ENTRYPOINT ["/usr/bin/tini", "--", "/app/docker-entrypoint.sh"]
# Set the working directory
WORKDIR /app
# Copy application files
COPY package*.json /app/
COPY docker-entrypoint.sh /app/
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
# Set non-root user permission
RUN chmod 555 /app/docker-entrypoint.sh
RUN chown -R node:node /app
RUN chmod -R 755 /app
USER node
EXPOSE 3000
ENV APP_NAME main
CMD ["--enable-source-maps", "dist/${APP_NAME}"]