James McCool commited on
Commit
12ff34e
·
1 Parent(s): faaa383

Refactor Dockerfile to remove the Bearer token curl request and update Streamlit app to retrieve MongoDB URI from environment variables instead of secrets. This change enhances security and simplifies the connection process.

Browse files
Files changed (2) hide show
  1. Dockerfile +0 -4
  2. src/streamlit_app.py +2 -2
Dockerfile CHANGED
@@ -19,10 +19,6 @@ 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 the secret SECRET_EXAMPLE at buildtime and use its value as a Bearer token for a curl request
23
- RUN --mount=type=secret,id=mongo_uri,mode=0444,required=true \
24
- curl test -H 'Authorization: Bearer $(cat /run/secrets/mongo_uri)'
25
-
26
  EXPOSE 8501
27
 
28
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
 
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
src/streamlit_app.py CHANGED
@@ -2,13 +2,13 @@ import numpy as np
2
  import pandas as pd
3
  import streamlit as st
4
  import pymongo
 
5
 
6
  st.set_page_config(layout="wide")
7
 
8
  @st.cache_resource
9
  def init_conn():
10
-
11
- uri = st.secrets['mongo_uri']
12
  client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
13
  db = client["MLB_Database"]
14
 
 
2
  import pandas as pd
3
  import streamlit as st
4
  import pymongo
5
+ import os
6
 
7
  st.set_page_config(layout="wide")
8
 
9
  @st.cache_resource
10
  def init_conn():
11
+ uri = os.getenv('mongo_uri')
 
12
  client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
13
  db = client["MLB_Database"]
14