Kaballas commited on
Commit
7c5c009
1 Parent(s): e4ddc67

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -16
Dockerfile CHANGED
@@ -1,16 +1,28 @@
1
- # Use the official PostgresML image
2
- FROM ghcr.io/postgresml/postgresml:2.7.12
3
- SECURITY_OPT="no-new-privileges:false"
4
- # Optional: Set environment variables if needed
5
- ENV POSTGRES_DB=postgresml
6
- ENV POSTGRES_USER=postgresml
7
-
8
- # Expose the necessary ports
9
- EXPOSE 5432 8000
10
-
11
- # Create a volume for persistent PostgreSQL data
12
- VOLUME ["/var/lib/postgresql"]
13
-
14
- # Set the default command to run when the container starts
15
- # This matches the original docker run command
16
- CMD ["sudo", "-u", "postgresml", "psql", "-d", "postgresml"]
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an appropriate base image
2
+ FROM python:3.9
3
+
4
+ # Create a user with specific permissions
5
+ RUN useradd -m -u 1000 user
6
+
7
+ # Set working directory
8
+ WORKDIR /app
9
+
10
+ # Copy requirements and install dependencies
11
+ COPY --chown=user ./requirements.txt requirements.txt
12
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
13
+
14
+ # Copy all project files
15
+ COPY --chown=user . /app
16
+
17
+ # Switch to non-root user
18
+ USER user
19
+
20
+ # Set environment variables
21
+ ENV HOME=/home/user \
22
+ PATH=/home/user/.local/bin:$PATH
23
+
24
+ # Expose the default Hugging Face Spaces port
25
+ EXPOSE 7860
26
+
27
+ # Default command to run the application
28
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]