Spaces:
Runtime error
Runtime error
File size: 4,588 Bytes
c6d4e5d 9f97180 db9f671 c6d4e5d db9f671 c6d4e5d db9f671 9f97180 e7c6240 c6d4e5d db9f671 c6d4e5d 9f97180 e7c6240 c6d4e5d 9f97180 e7c6240 c6d4e5d e27f03b c6d4e5d 9f97180 c6d4e5d e27f03b 9f97180 e27f03b c6d4e5d 9f97180 c6d4e5d 403c243 c6d4e5d e27f03b e7c6240 e27f03b e7c6240 dbe735d db9f671 e27f03b 9f97180 c6d4e5d 9f97180 e7c6240 c6d4e5d 9f97180 c6d4e5d | 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | FROM pspdfkit/ai-assistant:nightly
# Set environment variables
ENV HOME=/home/node \
PNPM_HOME=/root/.local/share/pnpm \
PATH=/root/.local/share/pnpm/bin:$PATH \
POSTGRES_USER=db-user \
POSTGRES_PASSWORD=password \
POSTGRES_DB=ai_assistant \
POSTGRES_INITDB_ARGS=--data-checksums \
PGDATA=/home/node/pgdata \
PGUSER=db-user \
PGPASSWORD=password \
PGDATABASE=ai_assistant \
PGHOST=localhost \
PGPORT=5432 \
API_AUTH_TOKEN=secret \
JWT_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2gzhmJ9TDanEzWdP1WG+\n0Ecwbe7f3bv6e5UUpvcT5q68IQJKP47AQdBAnSlFVi4X9SaurbWoXdS6jpmPpk24\nQvitzLNFphHdwjFBelTAOa6taZrSusoFvrtK9x5xsW4zzt/bkpUraNx82Z8MwLwr\nt6HlY7dgO9+xBAabj4t1d2t+0HS8O/ed3CB6T2lj6S8AbLDSEFc9ScO6Uc1XJlSo\nrgyJJSPCpNhSq3AubEZ1wMS1iEtgAzTPRDsQv50qWIbn634HLWxTP/UH6YNJBwzt\n3O6q29kTtjXlMGXCvin37PyX4Jy1IiPFwJm45aWJGKSfVGMDojTJbuUtM+8P9Rrn\nAwIDAQAB\n-----END PUBLIC KEY-----" \
JWT_ALGORITHM=RS256 \
DASHBOARD_USERNAME=dashboard \
DASHBOARD_PASSWORD=secret \
SECRET_KEY_BASE=secret-key-base
# Install system packages
RUN apk add --no-cache \
postgresql16 \
postgresql16-contrib \
py3-pip \
python3 \
py3-virtualenv \
wget \
curl \
unzip \
nginx \
procps \
build-base \
postgresql16-dev \
git && \
mkdir -p /run/postgresql && \
chown -R node:node /run/postgresql && \
# Install llamafiler
mkdir -p /tmp/llamafile && \
cd /tmp/llamafile && \
wget --no-check-certificate https://github.com/Mozilla-Ocho/llamafile/releases/download/0.8.17/llamafile-0.8.17.zip && \
unzip llamafile-0.8.17.zip && \
cp llamafile-0.8.17/bin/llamafiler /usr/local/bin/ && \
chmod +x /usr/local/bin/llamafiler && \
rm -rf /tmp/llamafile && \
mkdir -p /root/.local/share/pnpm && \
chmod -R 755 /root/.local/share/pnpm && \
chown -R node:node /root/.local/share/pnpm && \
# Ensure prisma is executable from PATH
ln -s /base/node_modules/.pnpm/prisma@5.11.0/node_modules/prisma/node_modules/.bin/prisma /usr/local/bin/prisma && \
chmod +x /usr/local/bin/prisma
# Install nginx and set up directories for non-root usage.
RUN mkdir -p /var/cache/nginx \
/var/log/nginx \
/var/lib/nginx && \
touch /var/run/nginx.pid && \
chown -R node:node /var/cache/nginx \
/var/log/nginx \
/var/lib/nginx \
/var/run/nginx.pid \
/run/nginx
# Copy application files to /base BEFORE switching user.
COPY --chown=node:node nginx.conf /etc/nginx/nginx.conf
COPY --chown=node:node start-services.sh /base/app/
COPY --chown=node:node service-config.yml /service-config.yml
USER node
RUN mkdir -p $HOME/models && \
mkdir -p $HOME/pgdata
# Install pgvector (needs root)
USER root
RUN git clone https://github.com/pgvector/pgvector.git && \
cd pgvector && \
make && \
make install && \
cd .. && \
rm -rf pgvector
# Download models as node user
USER node
RUN wget -q https://huggingface.co/bartowski/gemma-2-2b-it-GGUF/resolve/main/gemma-2-2b-it-Q4_K_M.gguf -O $HOME/models/gemma-2b.gguf && \
wget -q https://huggingface.co/leliuga/all-MiniLM-L6-v2-GGUF/resolve/main/all-MiniLM-L6-v2.F16.gguf -O $HOME/models/embeddings.gguf && \
chmod +x /base/app/start-services.sh
USER root
# Fix permissions for scripts and pnpm directory.
RUN chmod +x /base/app/start-services.sh && \
mkdir -p /root/.local/share/pnpm && \
chmod 755 /root && \
chmod 755 /root/.local && \
chmod 755 /root/.local/share && \
chmod -R 755 /root/.local/share/pnpm && \
chown -R node:node /root/.local/share/pnpm
# Set up document authoring in a separate directory
WORKDIR /docauth
# Create directory and set permissions
USER root
RUN mkdir -p /docauth && \
chown -R node:node /docauth && \
chmod -R 755 /docauth
USER node
# Copy the website that showcases the document authoring library.
COPY --chown=node:node index.html /docauth/index.html
COPY --chown=node:node document-authoring.js /docauth/document-authoring.js
COPY --chown=node:node Sample.docx /docauth/Sample.docx
EXPOSE 7860
USER root
# Fix permissions for the entire pnpm path.
RUN mkdir -p /root/.local/share/pnpm && \
chmod 755 /root && \
chmod 755 /root/.local && \
chmod 755 /root/.local/share && \
chmod -R 755 /root/.local/share/pnpm && \
chown -R node:node /root/.local/share/pnpm
USER node
WORKDIR /base
ENTRYPOINT []
CMD ["sh", "-c", "/base/app/start-services.sh"]
|