Update Dockerfile
Browse files- Dockerfile +12 -9
Dockerfile
CHANGED
@@ -9,15 +9,17 @@ ENV POETRY_VERSION=1.8.4 \
|
|
9 |
POETRY_CACHE_DIR=/tmp/poetry_cache \
|
10 |
PYTHONDONTWRITEBYTECODE=1
|
11 |
|
12 |
-
# Create
|
13 |
-
RUN
|
14 |
-
chmod 777 /data /app && \
|
15 |
-
useradd -m -u 1000 user && \
|
16 |
apt-get update && \
|
17 |
apt-get install -y sudo && \
|
18 |
usermod -aG sudo user && \
|
19 |
echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
20 |
|
|
|
|
|
|
|
|
|
21 |
# Install system dependencies
|
22 |
RUN apt-get update && apt-get install -y \
|
23 |
curl \
|
@@ -32,8 +34,7 @@ RUN apt-get update && apt-get install -y \
|
|
32 |
postgresql \
|
33 |
postgresql-contrib \
|
34 |
&& rm -rf /var/lib/apt/lists/* \
|
35 |
-
&& pip install --no-cache-dir "poetry==${POETRY_VERSION}"
|
36 |
-
&& chown -R postgres:postgres /var/lib/postgresql
|
37 |
|
38 |
# Initialize PostgreSQL database as postgres user
|
39 |
USER postgres
|
@@ -41,9 +42,13 @@ RUN /usr/lib/postgresql/15/bin/initdb -D /var/lib/postgresql/data && \
|
|
41 |
echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf && \
|
42 |
echo "listen_addresses='*'" >> /var/lib/postgresql/data/postgresql.conf
|
43 |
|
44 |
-
# Switch
|
45 |
USER user
|
46 |
|
|
|
|
|
|
|
|
|
47 |
# Pull official images
|
48 |
FROM langgenius/dify-web:latest AS web
|
49 |
FROM langgenius/dify-api:latest AS api
|
@@ -93,8 +98,6 @@ ENV FLASK_APP=app.py \
|
|
93 |
REDIS_PASSWORD=difyai123456 \
|
94 |
CELERY_BROKER_URL=amqp://guest:guest@localhost:5672// \
|
95 |
CELERY_RESULT_BACKEND=redis://localhost:6379/0 \
|
96 |
-
HOME=/home/user \
|
97 |
-
PATH=/home/user/.local/bin:$PATH \
|
98 |
PYTHONPATH=/app/api \
|
99 |
STORAGE_PATH=/data/storage
|
100 |
|
|
|
9 |
POETRY_CACHE_DIR=/tmp/poetry_cache \
|
10 |
PYTHONDONTWRITEBYTECODE=1
|
11 |
|
12 |
+
# Create non-root user first
|
13 |
+
RUN useradd -m -u 1000 user && \
|
|
|
|
|
14 |
apt-get update && \
|
15 |
apt-get install -y sudo && \
|
16 |
usermod -aG sudo user && \
|
17 |
echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
18 |
|
19 |
+
# Create directories with correct permissions
|
20 |
+
RUN mkdir -p /app/api /app/web /data/storage /var/lib/postgresql/data && \
|
21 |
+
chmod 777 /data /app /var/lib/postgresql/data
|
22 |
+
|
23 |
# Install system dependencies
|
24 |
RUN apt-get update && apt-get install -y \
|
25 |
curl \
|
|
|
34 |
postgresql \
|
35 |
postgresql-contrib \
|
36 |
&& rm -rf /var/lib/apt/lists/* \
|
37 |
+
&& pip install --no-cache-dir "poetry==${POETRY_VERSION}"
|
|
|
38 |
|
39 |
# Initialize PostgreSQL database as postgres user
|
40 |
USER postgres
|
|
|
42 |
echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf && \
|
43 |
echo "listen_addresses='*'" >> /var/lib/postgresql/data/postgresql.conf
|
44 |
|
45 |
+
# Switch to user for remaining operations
|
46 |
USER user
|
47 |
|
48 |
+
# Set environment for user
|
49 |
+
ENV HOME=/home/user \
|
50 |
+
PATH=/home/user/.local/bin:$PATH
|
51 |
+
|
52 |
# Pull official images
|
53 |
FROM langgenius/dify-web:latest AS web
|
54 |
FROM langgenius/dify-api:latest AS api
|
|
|
98 |
REDIS_PASSWORD=difyai123456 \
|
99 |
CELERY_BROKER_URL=amqp://guest:guest@localhost:5672// \
|
100 |
CELERY_RESULT_BACKEND=redis://localhost:6379/0 \
|
|
|
|
|
101 |
PYTHONPATH=/app/api \
|
102 |
STORAGE_PATH=/data/storage
|
103 |
|