File size: 843 Bytes
9afb3ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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"]