master
Kar 2025-02-14 01:23:16 +05:30
parent f96a50b7f4
commit 5777ee5131
2 changed files with 20 additions and 15 deletions

View File

@ -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 # Install dependencies
RUN npm install --omit=dev
WORKDIR /usr/src/iimtt_api
COPY package.json yarn.lock ./
USER node
RUN yarn install --pure-lockfile
# Copy the rest of the app's source code with correct ownership
COPY --chown=node:node . . 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"]

View File

@ -6,7 +6,7 @@
"main": "src/index.js", "main": "src/index.js",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": "22.13.1" "node": ">=12.0.0"
}, },
"scripts": { "scripts": {
"start": "NODE_ENV=production node src/index.js", "start": "NODE_ENV=production node src/index.js",