Giancarmine Salucci b728f19570
Some checks failed
Build and publish farmacia-bot images / Build and push client's image to Gitea's registry (push) Successful in 38s
Build and publish farmacia-bot images / deploy_ovh (push) Failing after 5s
arguments, fixes, dockerfile, ci
2025-04-15 13:10:17 +02:00

45 lines
1.2 KiB
Docker

# 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
# Create a non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Set working directory for the application
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
# Create logs directory with correct permissions
RUN mkdir -p logs && chown -R appuser:appgroup logs
# Expose logs directory as a volume
VOLUME ["/home/appuser/app/logs"]
# Use an environment variable for thread count (default to 0 to use auto)
ENV THREAD_COUNT=0
# Switch to non-root user
USER appuser
# Run the application - using JSON array format
CMD ["sh", "-c", "node main.js ${THREAD_COUNT}"]