jrosell commited on
Commit
d6ed967
·
1 Parent(s): c75f2cd
Files changed (3) hide show
  1. Dockerfile +6 -4
  2. README.md +13 -9
  3. app.R +7 -2
Dockerfile CHANGED
@@ -1,3 +1,4 @@
 
1
  FROM rocker/r2u:22.04
2
 
3
  WORKDIR /workspace
@@ -30,11 +31,12 @@ RUN set -eux; \
30
  ; \
31
  rm -rf /var/lib/apt/lists/*;
32
 
33
- RUN R -e "install.packages(c('htmltools', 'tidyverse', 'zeallot', 'rlang', 'glue', 'this.path', 'DBI', 'pool', 'RSQLite', 'remotes'))"
34
 
35
- RUN R -e "install.packages('b64', repos = c('https://extendr.r-universe.dev', 'https://cloud.r-project.org')); install.packages('uwu', repos = c('https://josiahparry.r-universe.dev', 'https://cloud.r-project.org'))"
36
 
37
- COPY . .
 
38
 
39
  EXPOSE 7860
40
- CMD R -e "print(Sys.getenv('GITHUB_PAT')); bspm::disable(); remotes::install_github(c('devOpifex/ambiorix', 'jrosell/ambhtmx', 'devOpifex/scilis', 'devOpifex/signaculum')); bspm::enable(); options(ambiorix.host='0.0.0.0', 'ambiorix.port'=7860);source('app.R')"
 
1
+ ARG GITHUB_PAT
2
  FROM rocker/r2u:22.04
3
 
4
  WORKDIR /workspace
 
31
  ; \
32
  rm -rf /var/lib/apt/lists/*;
33
 
34
+ RUN R -e " options(bspm.sudo = TRUE); install.packages(c('htmltools', 'tidyverse', 'zeallot', 'rlang', 'glue', 'this.path', 'DBI', 'pool', 'RSQLite', 'remotes', 'promises', 'assertthat', 'log'))"
35
 
36
+ RUN R -e "options(bspm.sudo = TRUE);install.packages('b64', repos = c('https://extendr.r-universe.dev', 'https://cloud.r-project.org')); install.packages('uwu', repos = c('https://josiahparry.r-universe.dev', 'https://cloud.r-project.org'))"
37
 
38
+ RUN adduser newuser
39
+ COPY --chown=newuser . .
40
 
41
  EXPOSE 7860
42
+ CMD R -e "print(length(Sys.getenv('GITHUB_PAT'))); options(bspm.sudo = TRUE); remotes::install_github(c('devOpifex/ambiorix', 'jrosell/ambhtmx', 'devOpifex/scilis', 'devOpifex/signaculum')); bspm::enable(); options(ambiorix.host='0.0.0.0', 'ambiorix.port'=7860);source('app.R')"
README.md CHANGED
@@ -10,27 +10,31 @@ pinned: false
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
11
 
12
 
13
- # Docker in local
14
 
15
- To create the image and run the container in Docker, run:
16
 
17
  ```
18
  docker build -f Dockerfile -t ambhtmx . \
19
  && docker run --env-file=.Renviron -p 7860:7860 --name ambhtmx-container --rm ambhtmx
20
  ```
21
 
22
- If you need an output folder:
 
23
  ```
24
- docker build -f Dockerfile -t ambhtmx . \
25
- && docker run -env-file=.Renviron -p 7860:7860 --name ambhtmx-container --rm -v $(pwd)/output:/workspace/output/:rw ambhtmx
 
 
26
  ```
27
 
28
 
29
- To stop, remove the container and create the image and run another container:
 
30
  ```
31
- docker container rm -f ambhtmx-container \
32
- && docker build -f Dockerfile -t ambhtmx . \
33
- && docker run --env-file=.Renviron -p 7860:7860 --name ambhtmx-container --rm ambhtmx
34
  ```
35
 
36
 
 
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
11
 
12
 
13
+ # Runing the example in Docker
14
 
15
+ First, you can create the image and test the container in Docker:
16
 
17
  ```
18
  docker build -f Dockerfile -t ambhtmx . \
19
  && docker run --env-file=.Renviron -p 7860:7860 --name ambhtmx-container --rm ambhtmx
20
  ```
21
 
22
+ If you want to rerun the process, you may need to remove the previous containers and images:
23
+
24
  ```
25
+ (docker container rm -f ambhtmx-container || true)\
26
+ && (docker rmi $(docker images --format '{{.Repository}}:{{.ID}}'| egrep 'ambhtmx' | cut -d':' -f2 | uniq) --force || true) \
27
+ && docker build -f Dockerfile -t ambhtmx . \
28
+ && docker run --env-file=.Renviron -p 7860:7860 --name ambhtmx-container --rm ambhtmx
29
  ```
30
 
31
 
32
+ If you need to read the output files from your host, run:
33
+
34
  ```
35
+ docker build -f Dockerfile -t ambhtmx . \
36
+ && docker run --env-file=.Renviron -p 7860:7860 --name ambhtmx-container --rm -v $(pwd)/output:/workspace/output/:rw ambhtmx
 
37
  ```
38
 
39
 
40
+
app.R CHANGED
@@ -85,14 +85,19 @@ c(app, context, items) %<-%
85
 
86
  #' Authentication feature with secret cookies and .Renviron variables
87
  app$get("/login", \(req, res) {
88
- process_login_get(req, res)
 
 
 
 
89
  })
90
  app$post("/login", \(req, res) {
91
  process_login_post(
92
  req,
93
  res,
94
  user = Sys.getenv("AMBHTMX_USER"),
95
- password = Sys.getenv("AMBHTMX_PASSWORD")
 
96
  )
97
  })
98
  app$get("/logout", \(req, res) {
 
85
 
86
  #' Authentication feature with secret cookies and .Renviron variables
87
  app$get("/login", \(req, res) {
88
+ process_login_get(
89
+ req,
90
+ res,
91
+ login_url = str_replace(req$HTTP_HOST, "0.0.0.0", "127.0.0.1")
92
+ )
93
  })
94
  app$post("/login", \(req, res) {
95
  process_login_post(
96
  req,
97
  res,
98
  user = Sys.getenv("AMBHTMX_USER"),
99
+ password = Sys.getenv("AMBHTMX_PASSWORD"),
100
+ login_url = str_replace(req$HTTP_HOST, "0.0.0.0", "127.0.0.1")
101
  )
102
  })
103
  app$get("/logout", \(req, res) {