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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -22
Dockerfile CHANGED
@@ -20,23 +20,31 @@ RUN apt-get update && apt-get install -y \
20
  libmpc-dev \
21
  nodejs \
22
  npm \
23
- postgresql-client \
 
 
24
  && rm -rf /var/lib/apt/lists/* \
25
- && pip install --no-cache-dir "poetry==${POETRY_VERSION}"
 
 
 
 
 
 
 
 
26
 
27
  # Pull official images
28
  FROM langgenius/dify-web:latest AS web
29
  FROM langgenius/dify-api:latest AS api
30
 
31
- # After base image setup and before final stage (around line 27)
32
- # Add PostgreSQL stage
33
- FROM postgres:15-alpine AS postgres
34
-
35
  # Final stage (continuing from line 32)
36
  FROM base
37
 
38
- # Create non-root user
39
- RUN useradd -m -u 1000 user
 
 
40
 
41
  # Set up directory structure
42
  WORKDIR /app
@@ -88,20 +96,6 @@ ENV FLASK_APP=app.py \
88
  USER user
89
  EXPOSE 7860 3000
90
 
91
- # Install PostgreSQL
92
- RUN apt-get update && apt-get install -y postgresql postgresql-contrib && \
93
- rm -rf /var/lib/apt/lists/* && \
94
- mkdir -p /var/lib/postgresql/data && \
95
- chown -R postgres:postgres /var/lib/postgresql
96
-
97
- # Initialize PostgreSQL database
98
- USER postgres
99
- RUN /usr/lib/postgresql/15/bin/initdb -D /var/lib/postgresql/data && \
100
- echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf && \
101
- echo "listen_addresses='*'" >> /var/lib/postgresql/data/postgresql.conf
102
-
103
- USER user
104
-
105
  # Create startup script with connection retries
106
  RUN echo '#!/bin/bash\n\
107
  echo "===== Application Startup at $(date "+%Y-%m-%d %H:%M:%S") ====="\n\
 
20
  libmpc-dev \
21
  nodejs \
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 \
29
+ && chown -R postgres:postgres /var/lib/postgresql
30
+
31
+ # Initialize PostgreSQL database as postgres user
32
+ USER postgres
33
+ 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
40
 
 
 
 
 
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
 
96
  USER user
97
  EXPOSE 7860 3000
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  # Create startup script with connection retries
100
  RUN echo '#!/bin/bash\n\
101
  echo "===== Application Startup at $(date "+%Y-%m-%d %H:%M:%S") ====="\n\