freddyaboulton HF staff commited on
Commit
cb9d76a
·
verified ·
1 Parent(s): 09c2946

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -0
Dockerfile ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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