node v
parent
f96a50b7f4
commit
5777ee5131
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
|
# 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"]
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Loading…
Reference in New Issue