Skip to content

Commit

Permalink
feat: add docker compose for local deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbeckmann committed Apr 30, 2024
1 parent 154d6d5 commit b75fe77
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
README.md
dev_local
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@


### Following R packages are used:
...
...

# Development

## Start a local opencpu server

* run `docker-compose up -d` in the `dev_local` directory of this repository
* run `docker-compose down` to stop the server
* open `http://localhost:80/ocpu/` in your browser to see the opencpu server
* test fearbase package by posting requests in `../library/fearbase/`
41 changes: 41 additions & 0 deletions dev_local/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM opencpu/base:latest

#install needed dependenciesp
RUN apt-get update && apt-get install -y \
libcurl4-gnutls-dev \
&& apt install -y cmake \
## clean up
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/ \
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds \
&& rm -rf /var/www/html/index.html

RUN cp /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/ && \
cp /etc/apache2/mods-available/headers.load /etc/apache2/mods-enabled/

RUN R -e "install.packages('devtools')"
RUN R -e "install.packages('remotes')"
RUN R -e "install.packages('ggplot2')"
RUN R -e "install.packages('meta')"
RUN R -e "install.packages('rlang')"
RUN R -e 'remove.packages("rlang", "/usr/lib/opencpu/library")'
RUN R -e 'remove.packages("vctrs", "/usr/lib/opencpu/library")'
RUN R -e "install.packages('vctrs')"

COPY . /home/opencpu/fearbase

RUN echo $(ls -1 /home/opencpu/fearbase) && sleep 1000

RUN cd /home/opencpu && \
R -e "install.packages('remotes')" && \
R CMD build fearbase && \
mv fearbase_*.tar.gz fearbase_latest.tar.gz && \
R CMD INSTALL fearbase_latest.tar.gz --library=/usr/local/lib/R/site-library








8 changes: 8 additions & 0 deletions dev_local/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
opencpu:
build:
context: ../
dockerfile: ./dev_local/Dockerfile
ports:
- 80:80
- 8004:8004

0 comments on commit b75fe77

Please sign in to comment.