Mariem-Daha commited on
Commit
edc02c6
·
verified ·
1 Parent(s): 8c33e8e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +47 -49
Dockerfile CHANGED
@@ -1,49 +1,47 @@
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 allowed_users.txt .
21
- COPY static/ ./static/
22
-
23
- # Create necessary directories with proper permissions
24
- RUN mkdir -p /tmp/uploads && chmod 777 /tmp/uploads
25
- RUN mkdir -p /app/credentials && chmod 777 /app/credentials
26
-
27
- # Expose port
28
- EXPOSE 7860
29
-
30
- # Set environment variables
31
- ENV PYTHONUNBUFFERED=1
32
-
33
- # Create startup script that handles credentials
34
- RUN echo '#!/bin/bash\n\
35
- if [ ! -z "$GOOGLE_APPLICATION_CREDENTIALS_JSON" ]; then\n\
36
- echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" > /app/credentials/credentials.json\n\
37
- export GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/credentials.json\n\
38
- echo "✓ Created credentials file from environment variable"\n\
39
- elif [ ! -z "$GOOGLE_APPLICATION_CREDENTIALS" ]; then\n\
40
- if [ ! -f "$GOOGLE_APPLICATION_CREDENTIALS" ]; then\n\
41
- echo "$GOOGLE_APPLICATION_CREDENTIALS" > /app/credentials/credentials.json\n\
42
- export GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/credentials.json\n\
43
- echo "✓ Created credentials file from GOOGLE_APPLICATION_CREDENTIALS"\n\
44
- fi\n\
45
- fi\n\
46
- exec uvicorn app:app --host 0.0.0.0 --port 7860' > /app/start.sh && chmod +x /app/start.sh
47
-
48
- # Run the application via startup script
49
- 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 static/ ./static/
20
+
21
+ # Create necessary directories with proper permissions
22
+ RUN mkdir -p /tmp/uploads && chmod 777 /tmp/uploads
23
+ RUN mkdir -p /app/credentials && chmod 777 /app/credentials
24
+
25
+ # Expose port
26
+ EXPOSE 7860
27
+
28
+ # Set environment variables
29
+ ENV PYTHONUNBUFFERED=1
30
+
31
+ # Create startup script that handles credentials
32
+ RUN echo '#!/bin/bash\n\
33
+ if [ ! -z "$GOOGLE_APPLICATION_CREDENTIALS_JSON" ]; then\n\
34
+ echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" > /app/credentials/credentials.json\n\
35
+ export GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/credentials.json\n\
36
+ echo " Created credentials file from environment variable"\n\
37
+ elif [ ! -z "$GOOGLE_APPLICATION_CREDENTIALS" ]; then\n\
38
+ if [ ! -f "$GOOGLE_APPLICATION_CREDENTIALS" ]; then\n\
39
+ echo "$GOOGLE_APPLICATION_CREDENTIALS" > /app/credentials/credentials.json\n\
40
+ export GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/credentials.json\n\
41
+ echo " Created credentials file from GOOGLE_APPLICATION_CREDENTIALS"\n\
42
+ fi\n\
43
+ fi\n\
44
+ exec uvicorn app:app --host 0.0.0.0 --port 7860' > /app/start.sh && chmod +x /app/start.sh
45
+
46
+ # Run the application via startup script
47
+ CMD ["/bin/bash", "/app/start.sh"]