freddyaboulton HF staff commited on
Commit
748b832
·
verified ·
1 Parent(s): db24876

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -30
Dockerfile CHANGED
@@ -1,38 +1,21 @@
1
  # Use pgvector with Postgres 17 as the base image
2
  FROM pgvector/pgvector:pg17
3
 
4
- # Switch to root to make initial changes
5
- USER root
6
-
7
- # Create the user required by HF Spaces (ID 1000)
8
- RUN useradd -m -u 1000 user
9
-
10
- # Set up the data directory with correct permissions
11
- RUN mkdir -p /data && \
12
- chown -R user:user /data && \
13
- chmod 777 /data
14
-
15
- # Create directory for postgres data
16
- RUN mkdir -p /var/lib/postgresql/data && \
17
- chown -R postgres:postgres /var/lib/postgresql/data && \
18
- chmod 700 /var/lib/postgresql/data
19
-
20
- # Set required environment variables
21
  ENV POSTGRES_PASSWORD=postgres
22
- ENV POSTGRES_HOST_AUTH_METHOD=md5
23
- ENV PGDATA=/data/postgresql/data
24
 
25
- # Create a script to initialize the admin user
26
- COPY --chown=postgres:postgres <<EOF /docker-entrypoint-initdb.d/init-user.sql
27
- CREATE USER "gradio-admin" WITH PASSWORD 'gradio-rag#$G421@345215';
28
- ALTER USER "gradio-admin" WITH SUPERUSER;
29
- EOF
30
 
31
- # Modify postgresql.conf to listen on port 80
32
- RUN echo "port = 7860" >> /usr/share/postgresql/postgresql.conf.sample
33
 
34
- # Expose port 80
35
- EXPOSE 7860
36
 
37
- # Switch back to postgres user for running the service
38
- USER postgres
 
1
  # Use pgvector with Postgres 17 as the base image
2
  FROM pgvector/pgvector:pg17
3
 
4
+ # Set environment variable for PostgreSQL password and data directory
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  ENV POSTGRES_PASSWORD=postgres
6
+ ENV PGDATA=/data/postgresql
 
7
 
8
+ # Create and configure the data directories
9
+ RUN mkdir -p /data/postgresql && \
10
+ chown -R postgres:postgres /data && \
11
+ chmod 777 /data && \
12
+ chmod 700 /data/postgresql
13
 
14
+ # Set the data directory as a volume
15
+ VOLUME /data
16
 
17
+ # Expose PostgreSQL port
18
+ EXPOSE 5432
19
 
20
+ # Switch to postgres user for running the service
21
+ USER postgres