File size: 2,972 Bytes
198cb09
d454b01
 
5937fb3
d454b01
029ea4c
d454b01
 
 
 
 
029ea4c
 
 
5937fb3
d454b01
 
b392634
 
 
 
 
 
 
 
d0db6de
 
 
 
 
 
 
b392634
5937fb3
 
d0db6de
b392634
115355f
5937fb3
 
 
 
 
 
115355f
5937fb3
 
 
 
 
 
 
e14b416
029ea4c
d454b01
2509e3a
5100142
 
2509e3a
 
 
 
 
 
5100142
d454b01
3387e98
d9de6b9
334d2a0
 
d454b01
 
d0db6de
d454b01
d9de6b9
 
 
 
940e285
334d2a0
 
3387e98
334d2a0
029ea4c
 
 
 
 
 
d454b01
33d2ebb
d0db6de
 
d454b01
334d2a0
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
95
96
FROM ghcr.io/open-webui/open-webui:main

# Install dependencies
# Install essential build tools and dependencies
RUN apt update && apt install -y \
    software-properties-common \
    gcc \
    curl \
    sudo \
    git-lfs \
    openssl \
    wget \
    jq \
    python3 \
    # We will install Node.js and npm using nvm or a direct method, not apt's potentially older versions
    && rm -rf /var/lib/apt/lists/*

# Create a new group (optional, but good practice)
RUN groupadd --system appuser

# Create a new user and add them to the 'appuser' group
# -m: Create the user's home directory
# -s /bin/bash: Set the default shell for the user
# -g appuser: Set the primary group for the user
RUN useradd --system -m -s /bin/bash -g appuser appuser
# Set the working directory to the user's home directory.
# All subsequent commands will operate relative to this directory.
WORKDIR /home/appuser
# Switch to the new user
USER appuser
# Set environment variables for the user (optional)
ENV HOME=/home/appuser

# Install nvm (Node Version Manager) and then use it to install Node.js and npm
# This ensures a clean and controlled Node.js/npm environment
ENV NVM_DIR /home/appuser/.nvm
RUN mkdir -p $NVM_DIR
ENV NODE_VERSION 22
# Specify a compatible Node.js version, matching the earlier error message's requirement

# Optionally, if a specific npm version is absolutely required by the application
# and not provided by the Node.js version installed by nvm:
# If a specific npm version like 11.5.2 was truly needed: npm install -g npm@11.5.2

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash  && \
    . "$NVM_DIR/nvm.sh" && \
    nvm install $NODE_VERSION && \
    nvm use $NODE_VERSION && \
    nvm alias default $NODE_VERSION && \
    npm install -g npm@latest

# Verify Node.js and npm versions
RUN . "$NVM_DIR/nvm.sh" &&  node -v && npm -v


# Set all cache directories to /tmp (writable)
ENV HF_HOME=/tmp/hf_cache
ENV HUGGINGFACE_HUB_CACHE=/tmp/hf_cache
ENV TRANSFORMERS_CACHE=/tmp/hf_cache
ENV SENTENCE_TRANSFORMERS_HOME=/tmp/hf_cache

# Override Open WebUI cache directories
ENV DATA_DIR=/tmp/open-webui-data
ENV STATIC_DIR=/tmp/static

# Copy sync scripts
COPY --chown=appuser:appuser ./sync_storage.py ${HOME}/sync_storage.py
COPY --chown=appuser:appuser ./start_with_sync.sh ${HOME}/start_with_sync.sh



# Set working directory
# WORKDIR /app

COPY --chown=appuser:appuser ./add_bash_util.sh ${HOME}/add_bash_util.sh
COPY --chown=appuser:appuser ./Caddyfile ${HOME}/Caddyfile
COPY --chown=appuser:appuser ./crypt.sh ${HOME}/crypt.sh
COPY --chown=appuser:appuser ./gemini ${HOME}/gemini
COPY --chown=appuser:appuser ./readeck.toml ${HOME}/readeck.toml

# Make scripts executable
RUN chmod +x ${HOME}/*.py  ${HOME}/*.sh

# Expose ports

EXPOSE 7860

HEALTHCHECK --interval=30s --timeout=10s --start-period=5s \
  CMD curl -f http://localhost:7860/ || exit 1




# Start with sync
ENTRYPOINT ["/home/appuser/start_with_sync.sh"]