chore: add app directory argument to DNS Dockerfile

This commit is contained in:
Matthew Lopez 2024-06-03 17:38:55 -04:00
parent c6b5ab0748
commit b1f8b98b11
No known key found for this signature in database
GPG Key ID: 302A6EE3D63B7E0E

View File

@ -1,8 +1,11 @@
# syntax=docker/dockerfile:1
ARG app_dir="/home/node/app"
# * Base Node.js image
FROM node:20-alpine AS base
WORKDIR /home/node/app
ARG app_dir
WORKDIR ${app_dir}
# * Installing production dependencies
@ -15,7 +18,7 @@ RUN --mount=type=bind,source=package.json,target=package.json \
# * Installing development dependencies and building the application
FROM dependencies AS build
FROM base AS build
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
@ -28,6 +31,7 @@ RUN npm run build
# * Running the final application
FROM base AS final
ARG app_dir
RUN npm install -g pm2
@ -36,7 +40,7 @@ USER node
COPY package.json .
COPY --from=dependencies /home/node/app/node_modules ./node_modules
COPY --from=build /home/node/app/dist ./dist
COPY --from=dependencies ${app_dir}/node_modules ${app_dir}/node_modules
COPY --from=build ${app_dir}/dist ${app_dir}/dist
CMD pm2 start . --no-daemon