fix dockerfile
Some checks failed
Build and publish farmacia-bot images / Build and push client's image to Gitea's registry (push) Failing after 14s
Build and publish farmacia-bot images / deploy_ovh (push) Has been skipped

This commit is contained in:
Giancarmine Salucci 2025-04-15 13:37:49 +02:00
parent 3ac4d95a41
commit dd7fe20233

View File

@ -1,31 +1,24 @@
FROM node:23-alpine
# Create a non-root user with specific UID and GID
RUN addgroup -g 1000 -S appgroup && adduser -u 1000 -S -G appgroup appuser
# Switch to non-root user
USER node
# Set working directory
WORKDIR /home/appuser/app
# Copy package files with correct ownership
COPY --chown=appuser:appgroup package*.json ./
COPY --chown=node:node package*.json ./
# Install dependencies
RUN npm install
# Copy application files with correct ownership
COPY --chown=appuser:appgroup main.js util.js worker.js ./
COPY --chown=node:node main.js util.js worker.js ./
# Create logs directory with correct permissions
RUN mkdir -p logs && chown -R appuser:appgroup logs
RUN mkdir -p app/logs && chown -R node:node app
# Expose logs directory as a volume
VOLUME ["/home/appuser/app/logs"]
VOLUME ["/home/node/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}"]
CMD ["sh", "-c", "node main.js ${THREAD_COUNT}"]