diff --git a/Dockerfile b/Dockerfile index 4e8ce46..fc5ccae 100644 --- a/Dockerfile +++ b/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 \ No newline at end of file +# Expose the application port +EXPOSE 3000 + +# Set environment variables (optional) +ENV NODE_ENV=production + +# Start the application +CMD ["npm", "run", "start"] diff --git a/package.json b/package.json index 4b0da56..0e70af1 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "main": "src/index.js", "license": "MIT", "engines": { - "node": "22.13.1" + "node": ">=12.0.0" }, "scripts": { "start": "NODE_ENV=production node src/index.js",