| # Use a Node.js base image | |
| FROM node:18-alpine | |
| USER root | |
| # Set build-time arguments with default paths | |
| ARG N8N_PATH=/usr/local/lib/node_modules/n8n | |
| ARG DATA_PATH=/root/.n8n | |
| ARG DATABASE_PATH=$DATA_PATH | |
| ARG LOG_PATH=$DATA_PATH/logs | |
| # Install required dependencies | |
| RUN apk add --no-cache git python3 py3-pip make g++ build-base | |
| # Install n8n globally | |
| RUN npm install -g n8n | |
| # Create necessary directories and set permissions | |
| RUN mkdir -p $LOG_PATH $N8N_PATH/uploads && chmod -R 777 $LOG_PATH $N8N_PATH | |
| # Set the working directory | |
| WORKDIR /data | |
| # Expose default n8n port | |
| EXPOSE 5678 | |
| # Define the default command to start n8n | |
| CMD ["n8n"] |