Mariem-Daha commited on
Commit
40daf0d
·
verified ·
1 Parent(s): 4ded6c8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +48 -50
Dockerfile CHANGED
@@ -1,50 +1,48 @@
1
- FROM python:3.11-slim
2
-
3
- WORKDIR /app
4
-
5
- # Install system dependencies
6
- RUN apt-get update && apt-get install -y \
7
- gcc \
8
- g++ \
9
- && rm -rf /var/lib/apt/lists/*
10
-
11
- # Copy requirements
12
- COPY requirements.txt .
13
- RUN pip install --no-cache-dir -r requirements.txt
14
-
15
- # Copy application files
16
- COPY app.py .
17
- COPY ocr_invoice.py .
18
- COPY cost_tracker.py .
19
- COPY auth.py .
20
- COPY setup_hf_credentials.py .
21
- COPY allowed_users.txt .
22
- COPY static/ ./static/
23
-
24
- # Create necessary directories with proper permissions
25
- RUN mkdir -p /tmp/uploads && chmod 777 /tmp/uploads
26
- RUN mkdir -p /app/credentials && chmod 777 /app/credentials
27
-
28
- # Expose port
29
- EXPOSE 7860
30
-
31
- # Set environment variables
32
- ENV PYTHONUNBUFFERED=1
33
-
34
- # Create startup script that handles credentials
35
- RUN echo '#!/bin/bash\n\
36
- if [ ! -z "$GOOGLE_APPLICATION_CREDENTIALS_JSON" ]; then\n\
37
- echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" > /app/credentials/credentials.json\n\
38
- export GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/credentials.json\n\
39
- echo "✓ Created credentials file from environment variable"\n\
40
- elif [ ! -z "$GOOGLE_APPLICATION_CREDENTIALS" ]; then\n\
41
- if [ ! -f "$GOOGLE_APPLICATION_CREDENTIALS" ]; then\n\
42
- echo "$GOOGLE_APPLICATION_CREDENTIALS" > /app/credentials/credentials.json\n\
43
- export GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/credentials.json\n\
44
- echo "✓ Created credentials file from GOOGLE_APPLICATION_CREDENTIALS"\n\
45
- fi\n\
46
- fi\n\
47
- exec uvicorn app:app --host 0.0.0.0 --port 7860' > /app/start.sh && chmod +x /app/start.sh
48
-
49
- # Run the application via startup script
50
- CMD ["/bin/bash", "/app/start.sh"]
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ gcc \
8
+ g++ \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ # Copy requirements
12
+ COPY requirements.txt .
13
+ RUN pip install --no-cache-dir -r requirements.txt
14
+
15
+ # Copy application files
16
+ COPY app.py .
17
+ COPY ocr_invoice.py .
18
+ COPY cost_tracker.py .
19
+ COPY setup_hf_credentials.py .
20
+ COPY static/ ./static/
21
+
22
+ # Create necessary directories with proper permissions
23
+ RUN mkdir -p /tmp/uploads && chmod 777 /tmp/uploads
24
+ RUN mkdir -p /app/credentials && chmod 777 /app/credentials
25
+
26
+ # Expose port
27
+ EXPOSE 7860
28
+
29
+ # Set environment variables
30
+ ENV PYTHONUNBUFFERED=1
31
+
32
+ # Create startup script that handles credentials
33
+ RUN echo '#!/bin/bash\n\
34
+ if [ ! -z "$GOOGLE_APPLICATION_CREDENTIALS_JSON" ]; then\n\
35
+ echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" > /app/credentials/credentials.json\n\
36
+ export GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/credentials.json\n\
37
+ echo " Created credentials file from environment variable"\n\
38
+ elif [ ! -z "$GOOGLE_APPLICATION_CREDENTIALS" ]; then\n\
39
+ if [ ! -f "$GOOGLE_APPLICATION_CREDENTIALS" ]; then\n\
40
+ echo "$GOOGLE_APPLICATION_CREDENTIALS" > /app/credentials/credentials.json\n\
41
+ export GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/credentials.json\n\
42
+ echo " Created credentials file from GOOGLE_APPLICATION_CREDENTIALS"\n\
43
+ fi\n\
44
+ fi\n\
45
+ exec uvicorn app:app --host 0.0.0.0 --port 7860' > /app/start.sh && chmod +x /app/start.sh
46
+
47
+ # Run the application via startup script
48
+ CMD ["/bin/bash", "/app/start.sh"]