Robaa commited on
Commit
4fced91
·
1 Parent(s): d5a3690

Remove unused entrypoint script and secret API key handling from Dockerfile; update app.py to correctly retrieve API key from environment variable

Browse files
Files changed (2) hide show
  1. Dockerfile +0 -14
  2. app.py +3 -1
Dockerfile CHANGED
@@ -12,18 +12,4 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
12
 
13
  COPY --chown=user . /app
14
 
15
- # Set the environment variable at runtime from the secret
16
- RUN --mount=type=secret,id=APIKey,mode=0444,required=true \
17
- echo "export APIKEY=$(cat /run/secrets/APIKey)" >> /home/user/.bashrc
18
-
19
- # Add a startup script to ensure environment variable is set
20
- RUN echo '#!/bin/bash\n\
21
- if [ -f /app/APIKey ]; then\n\
22
- export APIKEY=$(cat /app/APIKey)\n\
23
- fi\n\
24
- exec "$@"' > /app/entrypoint.sh && \
25
- chmod +x /app/entrypoint.sh
26
-
27
- # Use the entrypoint script
28
- ENTRYPOINT ["/app/entrypoint.sh"]
29
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
12
 
13
  COPY --chown=user . /app
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
app.py CHANGED
@@ -16,8 +16,10 @@ import tempfile
16
  app = FastAPI()
17
 
18
  # Load environment variables
19
- API_KEY = os.getenv("APIKEY")
 
20
  if not API_KEY:
 
21
  raise ValueError("API_KEY not set. Please configure your .env file or system environment.")
22
 
23
  # Global variables for models and ThreadPool
 
16
  app = FastAPI()
17
 
18
  # Load environment variables
19
+ API_KEY = os.environ.get("EXAMPLE")
20
+
21
  if not API_KEY:
22
+ print(API_KEY)
23
  raise ValueError("API_KEY not set. Please configure your .env file or system environment.")
24
 
25
  # Global variables for models and ThreadPool