Spaces:
Runtime error
Runtime error
Commit
·
3e6cafa
1
Parent(s):
eafdfca
new approach for secrets
Browse files- Dockerfile +7 -5
Dockerfile
CHANGED
@@ -2,10 +2,6 @@ FROM rocker/shiny-verse:latest
|
|
2 |
|
3 |
WORKDIR /code
|
4 |
|
5 |
-
# Expose the secret OPENAI_API_KEY at buildtime and use its value as an environment variable
|
6 |
-
RUN --mount=type=secret,id=OPENAI_API_KEY,mode=0444,required=true \
|
7 |
-
echo "OPENAI_API_KEY=$(cat /run/secrets/OPENAI_API_KEY)" >> .Renviron
|
8 |
-
|
9 |
# Install stable packages from CRAN
|
10 |
RUN install2.r --error \
|
11 |
shiny \
|
@@ -17,4 +13,10 @@ RUN install2.r --error \
|
|
17 |
|
18 |
COPY . .
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
WORKDIR /code
|
4 |
|
|
|
|
|
|
|
|
|
5 |
# Install stable packages from CRAN
|
6 |
RUN install2.r --error \
|
7 |
shiny \
|
|
|
13 |
|
14 |
COPY . .
|
15 |
|
16 |
+
# Create a script that reads the secret and exports it as an environment variable
|
17 |
+
RUN echo '#!/bin/sh' >> start.sh && \
|
18 |
+
echo 'export OPENAI_API_KEY=$(cat /run/secrets/openai_api_key)' >> start.sh && \
|
19 |
+
echo 'R --quiet -e "shiny::runApp(host='\''0.0.0.0'\'', port=7860)"' >> start.sh && \
|
20 |
+
chmod +x start.sh
|
21 |
+
|
22 |
+
CMD ["./start.sh"]
|