File size: 2,712 Bytes
ba2b0bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
FROM buildpack-deps:22.04-curl

# Set arguments that will be populated by Hugging Face secrets
ARG DB_TYPE
ARG DB_POSTGRESDB_DATABASE
ARG DB_POSTGRESDB_HOST
ARG DB_POSTGRESDB_PORT
ARG DB_POSTGRESDB_USER
ARG DB_POSTGRESDB_PASSWORD


# DB_TYPE Available option:
# 'sqlite' | 'mariadb' | 'mysqldb' | 'postgresdb'

# Set static and dynamic environment variables
ENV DEBIAN_FRONTEND=noninteractive \
    TZ=Asia/Jakarta \
    N8N_PORT=7860 \
    N8N_HOST=eikarna-n8n.hf.space \
    WEBHOOK_URL=https://eikarna-n8n.hf.space \
    USER=eikarna \
    HOME=/home/eikarna \
    # Set runtime environment variables from the build arguments
    DB_TYPE=${DB_TYPE} \
    DB_POSTGRESDB_DATABASE=${DB_POSTGRESDB_DATABASE} \
    DB_POSTGRESDB_HOST=${DB_POSTGRESDB_HOST} \
    DB_POSTGRESDB_PORT=${DB_POSTGRESDB_PORT} \
    DB_POSTGRESDB_USER=${DB_POSTGRESDB_USER} \
    DB_POSTGRESDB_PASSWORD=${DB_POSTGRESDB_PASSWORD} \
    DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED=false \
    N8N_ENCRYPTION_KEY=7124bcedb3c8d535c3dc99036a1a49c7bc3e33fb372e90c8e8a8c8311804bf0f \
    # Recommended setting to avoid permission warnings
    N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true

USER root

RUN useradd -m -u 1000 ${USER}

# Install dependencies with quiet flags to reduce build logs
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends \
    bash \
    unzip \
    git \
    git-lfs \
    curl \
    sudo \
    wget \
    ffmpeg \
    psmisc \
    aria2 \
    build-essential \
    libnss3-dev \
    libgdk-pixbuf2.0-dev \
    libgtk-3-dev \
    libxss-dev \
    zlib1g-dev \
    libncurses5-dev \
    libssl-dev \
    libreadline-dev \
    libffi-dev \
    libasound2 \
    make \
    libnss3 \
    software-properties-common > /dev/null 2>&1 && \
    rm -rf /var/lib/apt/lists/*

# Install Node.js and proxy with quiet flags
RUN curl -sL https://deb.nodesource.com/setup_22.x | sudo -E bash - > /dev/null 2>&1 && \
    apt-get -qq install -y nodejs > /dev/null 2>&1 && \
    npm install -g configurable-http-proxy --silent

# Install Python from source with output redirected to /dev/null to silence it
RUN cd /tmp && \
    wget -q https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tgz && \
    tar -xf Python-3.10.12.tgz && \
    cd Python-3.10.12 && \
    ./configure --enable-optimizations > /dev/null 2>&1 && \
    make -j8 install > /dev/null 2>&1 && \
    cd / && \
    rm -rf /tmp/Python-3.10.12 /tmp/Python-3.10.12.tgz

WORKDIR ${HOME}

# Install n8n with silent flag
RUN npm install n8n -g --silent
# Create the .n8n directory and set permissions so n8n doesn't have to do it at runtime
RUN mkdir -p ${HOME}/.n8n && chown -R ${USER}:${USER} ${HOME}

USER ${USER}

EXPOSE ${N8N_PORT}

CMD ["n8n", "start"]