generated from digitalservicebund/remix-application-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
57 lines (42 loc) · 1.55 KB
/
Dockerfile
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Download and install the dependencies for building the app
FROM node:22.4.1-alpine3.20 AS build-dependencies
WORKDIR /src
COPY ./package.json package-lock.json /src/
RUN npm ci --ignore-scripts
# Download and install the dependencies for running the app
FROM node:22.4.1-alpine3.20 AS production-dependencies
ENV NODE_ENV=production
WORKDIR /src
COPY ./package.json package-lock.json /src/
RUN npm ci --ignore-scripts
# Build the app
FROM node:22.4.1-alpine3.20 AS build
# Create app directory
WORKDIR /src
# Copy the build dependencies
COPY --from=build-dependencies /src/node_modules node_modules/
# Copy root level files
COPY package.json package-lock.json tailwind.config.js tsconfig.json postcss.config.js vite.config.ts ./
COPY app/ app/
COPY public/ public/
RUN npm run build
# Final image that runs the app
FROM node:22.4.1-alpine3.20
ENV NODE_ENV=production
ENV npm_config_cache=/tmp/.npm
WORKDIR /home/node/src
# Move only the files to the final image that are really needed
COPY package.json package-lock.json start.sh ./
COPY --from=production-dependencies /src/node_modules/ ./node_modules/
COPY --from=build /src/build/ ./build/
# We need to explicitly bring in the public folder here, so that dynamic PDF generation can happen on the server
COPY --from=build /src/public/ ./public/
# Make the start script executable
RUN chmod +x ./start.sh && \
# Ensure the node user owns all files in the working directory
chown -R node:node /home/node/src
# Switch to non-root user
USER node
EXPOSE 3000
ENTRYPOINT ["./start.sh"]
CMD ["npm", "run", "start"]