James McCool commited on
Commit
44d5cc1
·
1 Parent(s): 6c12e73

Refactor Dockerfile to expose MongoDB URI secret at build time and simplify the ENTRYPOINT command for the Streamlit app. This change enhances security by using secrets during the build process and improves clarity in the container startup configuration.

Browse files
Files changed (1) hide show
  1. Dockerfile +5 -5
Dockerfile CHANGED
@@ -14,13 +14,13 @@ COPY src/ ./src/
14
 
15
  RUN pip3 install -r requirements.txt
16
 
17
- # Set the environment variable from the secret during runtime
18
- ENV mongo_uri=""
 
 
19
 
20
  EXPOSE 8501
21
 
22
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
23
 
24
- # Use the secret as an environment variable during container runtime
25
- ENTRYPOINT --mount=type=secret,id=mongo_uri,target=/run/secrets/mongo_uri,mode=0444,required=true \
26
- sh -c 'export mongo_uri=$(cat /run/secrets/mongo_uri) && streamlit run src/streamlit_app.py --server.port=8501 --server.address=0.0.0.0'
 
14
 
15
  RUN pip3 install -r requirements.txt
16
 
17
+ # Expose the secret SECRET_EXAMPLE at buildtime and use its value as git remote URL
18
+ RUN --mount=type=secret,id=mongo_uri,mode=0444,required=true \
19
+ git init && \
20
+ git remote add origin $(cat /run/secrets/mongo_uri)
21
 
22
  EXPOSE 8501
23
 
24
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
25
 
26
+ ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]