jameshwade commited on
Commit
b57a5c0
·
1 Parent(s): 3e6cafa

add user to dockerfile

Browse files
Files changed (2) hide show
  1. Dockerfile +9 -6
  2. app.R +0 -2
Dockerfile CHANGED
@@ -1,5 +1,8 @@
1
  FROM rocker/shiny-verse:latest
2
 
 
 
 
3
  WORKDIR /code
4
 
5
  # Install stable packages from CRAN
@@ -13,10 +16,10 @@ RUN install2.r --error \
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"]
 
1
  FROM rocker/shiny-verse:latest
2
 
3
+ # Create a non-root user to run the application
4
+ RUN adduser --disabled-password --gecos "" appuser
5
+
6
  WORKDIR /code
7
 
8
  # Install stable packages from CRAN
 
16
 
17
  COPY . .
18
 
19
+ # Change the ownership of the /code directory to appuser
20
+ RUN chown -R appuser:appuser /code
21
+
22
+ # Switch to the appuser user
23
+ USER appuser
24
 
25
+ CMD ["R", "--quiet", "-e", "shiny::runApp(host='0.0.0.0', port=7860)"]
app.R CHANGED
@@ -6,8 +6,6 @@ library(glue)
6
 
7
  source("helper.R")
8
 
9
- cat("API Key", Sys.getenv("OPENAI_API_KEY"))
10
-
11
  ui <- page_sidebar(
12
  title = "Chatbot with R & OpenAI",
13
  theme = bs_theme(bootswatch = "vapor"),
 
6
 
7
  source("helper.R")
8
 
 
 
9
  ui <- page_sidebar(
10
  title = "Chatbot with R & OpenAI",
11
  theme = bs_theme(bootswatch = "vapor"),