Miroir commited on
Commit
d3fa1fe
·
1 Parent(s): 87ac8bd

changed docker build

Browse files
Dockerfile CHANGED
@@ -7,6 +7,20 @@ RUN useradd -m -u 1000 user
7
  RUN mkdir -p /tmp/fasttext_cache /app/logs && \
8
  chown -R user:user /tmp/fasttext_cache /app/logs
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  # Switch to user after setting up permissions
11
  USER user
12
  ENV PATH="/home/user/.local/bin:$PATH"
@@ -27,17 +41,4 @@ COPY --chown=user . .
27
  HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
28
  CMD curl -f http://localhost:7860/ || exit 1
29
 
30
- # Create startup script
31
- COPY --chown=user <<EOF /app/start.sh
32
- #!/bin/bash
33
- echo "Starting application..."
34
- echo "Checking MODEL_URL accessibility..."
35
- curl --head --silent --fail ${MODEL_URL} || (echo "ERROR: Cannot access MODEL_URL" && exit 1)
36
- echo "MODEL_URL is accessible"
37
- echo "Starting uvicorn server..."
38
- exec uvicorn app:app --host 0.0.0.0 --port 7860 --log-level info
39
- EOF
40
-
41
- RUN chmod +x /app/start.sh
42
-
43
  CMD ["/app/start.sh"]
 
7
  RUN mkdir -p /tmp/fasttext_cache /app/logs && \
8
  chown -R user:user /tmp/fasttext_cache /app/logs
9
 
10
+ # Install curl for healthcheck
11
+ RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Create startup script
14
+ RUN echo '#!/bin/bash\n\
15
+ echo "Starting application..."\n\
16
+ echo "Checking MODEL_URL accessibility..."\n\
17
+ curl --head --silent --fail ${MODEL_URL} || (echo "ERROR: Cannot access MODEL_URL" && exit 1)\n\
18
+ echo "MODEL_URL is accessible"\n\
19
+ echo "Starting uvicorn server..."\n\
20
+ exec uvicorn app:app --host 0.0.0.0 --port 7860 --log-level info' > /app/start.sh && \
21
+ chmod +x /app/start.sh && \
22
+ chown user:user /app/start.sh
23
+
24
  # Switch to user after setting up permissions
25
  USER user
26
  ENV PATH="/home/user/.local/bin:$PATH"
 
41
  HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
42
  CMD curl -f http://localhost:7860/ || exit 1
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  CMD ["/app/start.sh"]
app.py CHANGED
@@ -24,6 +24,21 @@ app.add_middleware(
24
  allow_headers=["*"],
25
  )
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  # Initialize services
28
  try:
29
  word_service = WordEmbeddingService()
 
24
  allow_headers=["*"],
25
  )
26
 
27
+ # At the top of app.py, add:
28
+ import socket
29
+ import platform
30
+
31
+ @app.on_event("startup")
32
+ async def startup_event():
33
+ """Log information about the environment when the application starts"""
34
+ logger.info("=" * 40)
35
+ logger.info("Starting Semantix API")
36
+ logger.info(f"Python version: {platform.python_version()}")
37
+ logger.info(f"Host: {socket.gethostname()}")
38
+ logger.info(f"Model URL: {os.getenv('MODEL_URL')}")
39
+ logger.info("=" * 40)
40
+
41
+
42
  # Initialize services
43
  try:
44
  word_service = WordEmbeddingService()
config/__pycache__/game_config.cpython-311.pyc DELETED
Binary file (2.77 kB)
 
requirements.txt CHANGED
@@ -7,4 +7,6 @@ python-dotenv==1.0.0
7
  loguru==0.7.2
8
  requests==2.31.0
9
  scikit-learn==1.3.2
10
- umap-learn==0.5.5
 
 
 
7
  loguru==0.7.2
8
  requests==2.31.0
9
  scikit-learn==1.3.2
10
+ umap-learn==0.5.5
11
+ requests==2.31.0
12
+ pydantic==2.5.2