Simplify Dockerfile

This commit is contained in:
Juan Calderon-Perez 2023-11-19 10:51:22 -05:00 committed by GitHub
parent e1d1df076e
commit 569559a8fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 11 deletions

View File

@ -1,26 +1,22 @@
ARG NODE_VERSION=20.0.0
FROM node:${NODE_VERSION}-alpine
FROM node:20-alpine
ENV NODE_ENV production
WORKDIR /app
RUN --mount=type=bind,source=package.json,target=package.json \
    --mount=type=bind,source=package-lock.json,target=package-lock.json \
    --mount=type=cache,target=/root/.npm
# Run the application as a root user.
USER root
# Install dependencies
COPY package.json package-lock.json* ./
RUN npm ci --omit=dev
# Copy the rest of the source files into the image.
COPY . .
# Run the application as a root user.
USER root
# Expose the port that the application listens on.
EXPOSE 8000
# Run the application.
CMD node app.js