File size: 2,267 Bytes
11713e2
223cfa0
11713e2
 
 
 
 
 
 
bb4e756
ae4b824
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223cfa0
f8dcf7b
 
 
 
11713e2
f8dcf7b
bc03f82
0ac823c
5c841e4
 
7cd55fc
 
5c841e4
0ac823c
11713e2
 
 
0ac823c
11713e2
4215a8b
0ac823c
11713e2
17c0c8b
0ac823c
 
 
 
 
17c0c8b
0ac823c
 
17c0c8b
0ac823c
11713e2
 
0ac823c
11713e2
223cfa0
aabe5da
4d7c889
17c0c8b
0ac823c
f8dcf7b
bc03f82
d3deb2e
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
FROM node:18-alpine

# Arguments that can be passed at build time
ARG N8N_PATH=/usr/local/lib/node_modules/n8n
ARG BASE_PATH=/root/.n8n
ARG DATABASE_PATH=$BASE_PATH/database
ARG CONFIG_PATH=$BASE_PATH/config
ARG WORKFLOWS_PATH=$BASE_PATH/workflows
ARG LOGS_PATH=$BASE_PATH/logs
ARG N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=$N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS
ARG N8N_HOST=$N8N_HOST
ARG N8N_PORT=$N8N_PORT
ARG N8N_PROTOCOL=https
ARG N8N_EDITOR_BASE_URL=$N8N_EDITOR_BASE_URL
ARG WEBHOOK_URL=$WEBHOOK_URL
ARG GENERIC_TIMEZONE=$GENERIC_TIMEZONE
ARG TZ=$TZ
ARG N8N_ENCRYPTION_KEY=$N8N_ENCRYPTION_KEY
ARG DB_TYPE=$DB_TYPE
ARG DB_POSTGRESDB_SCHEMA=$DB_POSTGRESDB_SCHEMA
ARG DB_POSTGRESDB_HOST=$DB_POSTGRESDB_HOST
ARG DB_POSTGRESDB_DATABASE=$DB_POSTGRESDB_DATABASE
ARG DB_POSTGRESDB_PORT=$DB_POSTGRESDB_PORT
ARG DB_POSTGRESDB_USER=$DB_POSTGRESDB_USER
ARG DB_POSTGRESDB_PASSWORD=$DB_POSTGRESDB_PASSWORD

# Change Alpine mirror - Using Aliyun mirror for faster downloads in China
RUN echo "http://mirrors.aliyun.com/alpine/v3.18/main" > /etc/apk/repositories && \
    echo "http://mirrors.aliyun.com/alpine/v3.18/community" >> /etc/apk/repositories

# Install system dependencies
RUN apk update || echo "apk update failed" && exit 1
RUN apk add --no-cache --update-cache git python3 py3-pip make g++ build-base cairo-dev pango-dev chromium postgresql-client ffmpeg fontconfig dejavu-fonts yt-dlp || echo "apk add failed" && exit 1

# Install custom fonts
RUN mkdir -p /usr/share/fonts/truetype/custom
COPY ./fonts/HanyiSentyPagoda_Regular.ttf /usr/share/fonts/truetype/custom/
RUN chmod 644 /usr/share/fonts/truetype/custom/HanyiSentyPagoda_Regular.ttf # 确保字体文件具有读取权限
RUN fc-cache -f -v

# Set environment variables
ENV PUPPETEER_SKIP_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

# Install n8n globally
RUN npm install -g [email protected]

# Create necessary directories
RUN mkdir -p $DATABASE_PATH $CONFIG_PATH $WORKFLOWS_PATH $LOGS_PATH

# Add group and user.  Using a different UID/GID to avoid conflicts.
RUN addgroup -g 1001 n8n && \
    adduser -u 1001 -G n8n -s /bin/sh -D n8n

RUN chown -R n8n:n8n $BASE_PATH

# Switch to the n8n user.
USER n8n

# Set working directory
WORKDIR /data

# Start n8n
CMD ["n8n", "start"]