olamideba commited on
Commit
1809adb
·
1 Parent(s): a37ea7b

Refactor Dockerfile to use a Python entrypoint script for asset downloading and Streamlit startup; add new entrypoint.py script.

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -6
  2. app/scripts/entrypoint.py +28 -0
Dockerfile CHANGED
@@ -15,13 +15,8 @@ COPY . .
15
 
16
  ENV PYTHONPATH=/app/app
17
 
18
- # Create entrypoint script
19
- RUN echo '#!/bin/bash\n\
20
- python3 -m app.scripts.download_assets\n\
21
- exec streamlit run app/main.py --server.port=8501 --server.address=0.0.0.0\n\
22
- ' > /entrypoint.sh && chmod +x /entrypoint.sh
23
 
24
  EXPOSE 8501
25
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
26
 
27
- ENTRYPOINT ["/entrypoint.sh"]
 
15
 
16
  ENV PYTHONPATH=/app/app
17
 
 
 
 
 
 
18
 
19
  EXPOSE 8501
20
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
21
 
22
+ ENTRYPOINT ["python3", "-m", "app.scripts.entrypoint"]
app/scripts/entrypoint.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Entrypoint script that downloads assets and starts Streamlit.
4
+ """
5
+ import sys
6
+ import subprocess
7
+
8
+ def main():
9
+ # Download assets first
10
+ print("Downloading assets...")
11
+ try:
12
+ from app.scripts.download_assets import main as download_main
13
+ download_main()
14
+ except Exception as e:
15
+ print(f"Warning: Asset download failed: {e}")
16
+ print("Continuing anyway...")
17
+
18
+ # Start Streamlit (this replaces the Python process)
19
+ print("Starting Streamlit...")
20
+ sys.exit(subprocess.run([
21
+ "streamlit", "run",
22
+ "app/main.py",
23
+ "--server.port=8501",
24
+ "--server.address=0.0.0.0"
25
+ ]).returncode)
26
+
27
+ if __name__ == "__main__":
28
+ main()