node v
This commit is contained in:
33
Dockerfile
33
Dockerfile
@@ -1,21 +1,26 @@
|
||||
ARG NODE_VERSION=18
|
||||
# Use an official Node.js runtime as a parent image
|
||||
FROM node:20-alpine
|
||||
|
||||
FROM node:${NODE_VERSION}-alpine
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV production
|
||||
# Copy package files and set ownership
|
||||
COPY --chown=node:node package*.json ./
|
||||
|
||||
RUN mkdir -p /usr/src/iimtt_api && chown -R node:node /usr/src/iimtt_api
|
||||
|
||||
WORKDIR /usr/src/iimtt_api
|
||||
|
||||
COPY package.json yarn.lock ./
|
||||
|
||||
USER node
|
||||
|
||||
RUN yarn install --pure-lockfile
|
||||
# Install dependencies
|
||||
RUN npm install --omit=dev
|
||||
|
||||
# Copy the rest of the app's source code with correct ownership
|
||||
COPY --chown=node:node . .
|
||||
|
||||
EXPOSE 5174
|
||||
# Use a non-root user for better security
|
||||
USER node
|
||||
|
||||
CMD yarn start
|
||||
# Expose the application port
|
||||
EXPOSE 3000
|
||||
|
||||
# Set environment variables (optional)
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Start the application
|
||||
CMD ["npm", "run", "start"]
|
||||
|
||||
Reference in New Issue
Block a user