single stage Dockerfile
This commit is contained in:
parent
bd053cfb73
commit
dcaf485131
34
Dockerfile
34
Dockerfile
@ -1,33 +1,19 @@
|
|||||||
# Build stage
|
FROM node:23-alpine
|
||||||
FROM node:23-alpine AS builder
|
|
||||||
|
|
||||||
# Set working directory for the build stage
|
|
||||||
WORKDIR /build
|
|
||||||
|
|
||||||
# Copy package files
|
|
||||||
COPY package*.json ./
|
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
# Copy application files
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Runtime stage
|
|
||||||
FROM node:23-alpine AS runtime
|
|
||||||
|
|
||||||
# Create a non-root user
|
# Create a non-root user
|
||||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||||
|
|
||||||
# Set working directory for the application
|
# Set working directory
|
||||||
WORKDIR /home/appuser/app
|
WORKDIR /home/appuser/app
|
||||||
|
|
||||||
# Copy only the necessary files from the builder stage
|
# Copy package files with correct ownership
|
||||||
COPY --from=builder --chown=appuser:appgroup /build/package*.json ./
|
COPY --chown=appuser:appgroup package*.json ./
|
||||||
COPY --from=builder --chown=appuser:appgroup /build/main.js ./
|
|
||||||
COPY --from=builder --chown=appuser:appgroup /build/util.js ./
|
# Install dependencies
|
||||||
COPY --from=builder --chown=appuser:appgroup /build/worker.js ./
|
RUN npm install
|
||||||
COPY --from=builder --chown=appuser:appgroup /build/node_modules ./node_modules
|
|
||||||
|
# Copy application files with correct ownership
|
||||||
|
COPY --chown=appuser:appgroup main.js util.js worker.js ./
|
||||||
|
|
||||||
# Create logs directory with correct permissions
|
# Create logs directory with correct permissions
|
||||||
RUN mkdir -p logs && chown -R appuser:appgroup logs
|
RUN mkdir -p logs && chown -R appuser:appgroup logs
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user