N8N / Dockerfile
srinuksv's picture
Create Dockerfile
9afb3ea verified
raw
history blame contribute delete
843 Bytes
# Use the official Node.js image as the base image
FROM node:20-alpine
# Set environment variables for n8n
ENV N8N_VERSION=1.16.0 \
N8N_USER=n8n \
N8N_HOME=/home/n8n
# Create a non-root user
RUN addgroup -S $N8N_USER && adduser -S $N8N_USER -G $N8N_USER
# Create a working directory
WORKDIR $N8N_HOME
# Install dependencies
RUN apk add --no-cache \
bash \
tini \
python3 \
py3-pip \
libc6-compat \
openssh-client \
curl \
git
# Install n8n globally
RUN npm install -g n8n@$N8N_VERSION
# Change ownership to the n8n user
RUN chown -R $N8N_USER:$N8N_USER $N8N_HOME
# Switch to the non-root user
USER $N8N_USER
# Expose the default n8n port
EXPOSE 5678
# Use tini to handle process signals correctly
ENTRYPOINT ["tini", "--"]
# Start n8n with authentication from environment variables
CMD ["n8n"]