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 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
|
||||
FROM node:23-alpine
|
||||
|
||||
# Create a non-root user
|
||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||
|
||||
# Set working directory for the application
|
||||
# Set working directory
|
||||
WORKDIR /home/appuser/app
|
||||
|
||||
# Copy only the necessary files from the builder stage
|
||||
COPY --from=builder --chown=appuser:appgroup /build/package*.json ./
|
||||
COPY --from=builder --chown=appuser:appgroup /build/main.js ./
|
||||
COPY --from=builder --chown=appuser:appgroup /build/util.js ./
|
||||
COPY --from=builder --chown=appuser:appgroup /build/worker.js ./
|
||||
COPY --from=builder --chown=appuser:appgroup /build/node_modules ./node_modules
|
||||
# Copy package files with correct ownership
|
||||
COPY --chown=appuser:appgroup package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
# Copy application files with correct ownership
|
||||
COPY --chown=appuser:appgroup main.js util.js worker.js ./
|
||||
|
||||
# Create logs directory with correct permissions
|
||||
RUN mkdir -p logs && chown -R appuser:appgroup logs
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user