Severian commited on
Commit
d0ebb79
·
verified ·
1 Parent(s): 704d8a2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -7
Dockerfile CHANGED
@@ -9,6 +9,13 @@ ENV POETRY_VERSION=1.8.4 \
9
  POETRY_CACHE_DIR=/tmp/poetry_cache \
10
  PYTHONDONTWRITEBYTECODE=1
11
 
 
 
 
 
 
 
 
12
  # Install system dependencies
13
  RUN apt-get update && apt-get install -y \
14
  curl \
@@ -22,7 +29,6 @@ RUN apt-get update && apt-get install -y \
22
  npm \
23
  postgresql \
24
  postgresql-contrib \
25
- sudo \
26
  && rm -rf /var/lib/apt/lists/* \
27
  && pip install --no-cache-dir "poetry==${POETRY_VERSION}" \
28
  && mkdir -p /var/lib/postgresql/data \
@@ -34,6 +40,9 @@ RUN /usr/lib/postgresql/15/bin/initdb -D /var/lib/postgresql/data && \
34
  echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf && \
35
  echo "listen_addresses='*'" >> /var/lib/postgresql/data/postgresql.conf
36
 
 
 
 
37
  # Pull official images
38
  FROM langgenius/dify-web:latest AS web
39
  FROM langgenius/dify-api:latest AS api
@@ -41,11 +50,6 @@ FROM langgenius/dify-api:latest AS api
41
  # Final stage (continuing from line 32)
42
  FROM base
43
 
44
- # Create non-root user and add to sudo group
45
- RUN useradd -m -u 1000 user && \
46
- usermod -aG sudo user && \
47
- echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
48
-
49
  # Set up directory structure
50
  WORKDIR /app
51
  RUN mkdir -p api web /data/storage && \
@@ -93,7 +97,6 @@ ENV FLASK_APP=app.py \
93
  PYTHONPATH=/app/api \
94
  STORAGE_PATH=/data/storage
95
 
96
- USER user
97
  EXPOSE 7860 3000
98
 
99
  # Create startup script with connection retries
 
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
  # Install system dependencies
20
  RUN apt-get update && apt-get install -y \
21
  curl \
 
29
  npm \
30
  postgresql \
31
  postgresql-contrib \
 
32
  && rm -rf /var/lib/apt/lists/* \
33
  && pip install --no-cache-dir "poetry==${POETRY_VERSION}" \
34
  && mkdir -p /var/lib/postgresql/data \
 
40
  echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf && \
41
  echo "listen_addresses='*'" >> /var/lib/postgresql/data/postgresql.conf
42
 
43
+ # Switch back to user for remaining operations
44
+ USER user
45
+
46
  # Pull official images
47
  FROM langgenius/dify-web:latest AS web
48
  FROM langgenius/dify-api:latest AS api
 
50
  # Final stage (continuing from line 32)
51
  FROM base
52
 
 
 
 
 
 
53
  # Set up directory structure
54
  WORKDIR /app
55
  RUN mkdir -p api web /data/storage && \
 
97
  PYTHONPATH=/app/api \
98
  STORAGE_PATH=/data/storage
99
 
 
100
  EXPOSE 7860 3000
101
 
102
  # Create startup script with connection retries