Spaces:
Running
Running
align to new docs
Browse files- Dockerfile +8 -1
- main.py +3 -1
Dockerfile
CHANGED
@@ -7,6 +7,13 @@ COPY ./requirements.txt /code/requirements.txt
|
|
7 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
|
9 |
COPY ./main.py /code/app/main.py
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
7 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
|
9 |
COPY ./main.py /code/app/main.py
|
10 |
+
|
11 |
+
# Get secret EXAMPLE and output it to /test at buildtime
|
12 |
+
RUN --mount=type=secret,id=EXAMPLE,mode=0444,required=true \
|
13 |
+
cat /run/secrets/EXAMPLE > /test
|
14 |
+
|
15 |
+
# Get secret SECRET_EXAMPLE and clone it as repo at buildtime
|
16 |
+
RUN --mount=type=secret,id=SECRET_EXAMPLE,mode=0444,required=true \
|
17 |
+
git clone $(cat /run/secrets/SECRET_EXAMPLE)
|
18 |
|
19 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
main.py
CHANGED
@@ -8,4 +8,6 @@ app = FastAPI()
|
|
8 |
|
9 |
@app.get("/")
|
10 |
def read_root():
|
11 |
-
return {"Hello": os.environ.get("EXAMPLE")
|
|
|
|
|
|
8 |
|
9 |
@app.get("/")
|
10 |
def read_root():
|
11 |
+
return {"Hello EXAMPLE": os.environ.get("EXAMPLE"),
|
12 |
+
"Hello SECRET_EXAMPLE": os.environ.get("SECRET_EXAMPLE")
|
13 |
+
}
|