Update docker file
This commit is contained in:
@@ -1,28 +1,38 @@
|
|||||||
# Use an official Node.js image as the base
|
# --- Stage 1: Build & Install Dependencies ---
|
||||||
FROM node:22.14.0-alpine
|
FROM node:22.14.0-alpine AS builder
|
||||||
|
|
||||||
# Set the working directory in the container
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package.json and package-lock.json (if you want to use the lock file)
|
# Copy package.json and lock file (if used) from source subdir
|
||||||
# If your local lock file is platform-specific, add 'package-lock.json' to .dockerignore
|
COPY /src/Managing.Web3Proxy/package*.json ./
|
||||||
COPY src/Managing.Web3Proxy/package*.json ./
|
|
||||||
|
|
||||||
# Declaring env
|
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV production
|
||||||
|
|
||||||
# Install dependencies in the correct environment
|
# Install dependencies (development dependencies are fine here)
|
||||||
# We remove the "npm install --package-lock-only" step.
|
|
||||||
# "npm ci" requires a lock file, "npm install" will generate one if absent.
|
|
||||||
RUN npm ci --no-audit --fund=false
|
RUN npm ci --no-audit --fund=false
|
||||||
# If you don't have a local package-lock.json or are ignoring it, use "npm install" instead of "npm ci"
|
|
||||||
|
|
||||||
# Copy the rest of the application source code
|
# Copy the rest of the source code
|
||||||
COPY src/Managing.Web3Proxy/ .
|
COPY src/Managing.Web3Proxy/ .
|
||||||
|
|
||||||
# Build the app (if 'build' script involves TS compilation, it should be fine here)
|
# Run the build script
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
# --- Stage 2: Production Runtime ---
|
||||||
|
FROM node:22.14.0-alpine AS production
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy essential files from the builder stage
|
||||||
|
COPY --from=builder /app/package*.json ./
|
||||||
|
COPY --from=builder /app/node_modules/ ./node_modules/
|
||||||
|
# Copy the compiled application code (assuming 'dist' is the output folder)
|
||||||
|
COPY --from=builder /app/dist/ ./dist/
|
||||||
|
|
||||||
|
# Set production environment again for the runtime stage
|
||||||
|
ENV NODE_ENV production
|
||||||
|
|
||||||
EXPOSE 4111
|
EXPOSE 4111
|
||||||
|
|
||||||
CMD ["npm", "run", "start"]
|
# Start the application from the compiled output
|
||||||
|
CMD ["fastify", "start", "-l", "info", "dist/app.js"]
|
||||||
|
|
||||||
Reference in New Issue
Block a user