diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d644ec6e3d4b22c232fd97b772eb70392cfa33bd..8a8ca498e455c0438e97de5f1e154fdcb44af2fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,7 @@ build: --cache-from "$CI_REGISTRY_IMAGE/master:latest" --tag "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA" --tag "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest" - -f Dockerfile2 + -f Dockerfile ./ # push image as latest for the current branch - docker push "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest" diff --git a/Dockerfile b/Dockerfile index 41c3af4c096f67e31d79bc44088ecffc186e2117..34874c517ed35edd22799324d26fe24d1516bad3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,45 +1,44 @@ -FROM rocker/shiny:4.2.3 - -RUN cp -r $R_HOME /usr/myR - -ENV R_HOME=/usr/myR - -RUN R -e 'print("hello world")' - -WORKDIR /srv/shiny-server/ - -USER root - -# RUN sed -i "s/test -x/test -d/g" /usr/local/bin/R -# RUN sed -i '/test -x/,+4d' /usr/local/bin/R - -# RUN grep " \${gui}" /usr/local/bin/R -A 10 - -# change permission for user shiny -# RUN sudo chown -R shiny:shiny /usr/local/lib/R/etc/ - -## Install R packages from CRAN or bioconductor -# COPY ./script_r_to_docker/script_install_r_packages.R . -# COPY ./script_r_to_docker/packages_to_install.csv . - -#RUN ls -lah /usr/local/lib/R -#RUN printenv - -# RUN /usr/local/lib/R/bin/Rscript script_install_r_packages.R -# RUN Rscript script_install_r_packages.R - -RUN R -e 'print("hello world")' +FROM ubuntu:focal + +# define geographic location during R installation +ENV TZ=Etc/UTC +ENV DEBIAN_FRONTEND noninteractive +ARG SHINY_SERVER_VERSION + +EXPOSE 3838 +CMD ["shiny-server"] + +# install R +RUN apt-get update \ + && apt-get install -y \ + nano \ + wget \ + curl \ + r-base \ + r-base-dev \ + r-recommended \ + lsb-release \ + && rm -rf /var/lib/apt/lists/* \ + && R --version + +COPY ./scripts /opt/scripts + +# Install R packages included Shiny, then install shiny server +RUN Rscript /opt/scripts/install_r_packages.R +RUN /opt/scripts/install_shiny_server.sh + +# allows trafic from all ips +RUN sed -i "s/3838/3838 0.0.0.0/g" /etc/shiny-server/shiny-server.conf + +# copy my shiny app. +COPY ./example_proj /srv/shiny-server -ENV OPENBLAS_NUM_THREADS=1 +#RUN chown shiny:shiny /var/lib/shiny-server +RUN mkdir -p /var/log/shiny-server \ + && chown shiny:shiny /var/log/shiny-server -RUN install2.r \ - shinythemes +# USER shiny -# copy the app directory into the image -COPY ./example_proj /srv/shiny-server -RUN ls /srv/shiny-server -USER shiny -# CMD ["/usr/bin/shiny-server"] diff --git a/Dockerfile2 b/Dockerfile2 deleted file mode 100644 index 50ddb1196edddbbe0e6ed97108471c954edd52d5..0000000000000000000000000000000000000000 --- a/Dockerfile2 +++ /dev/null @@ -1,71 +0,0 @@ -#FROM rocker/shiny -FROM ubuntu:focal -# define geographic location during R installation -ENV TZ=Etc/UTC -ENV DEBIAN_FRONTEND noninteractive - -# install R -RUN apt-get update \ - && apt-get install -y \ - nano \ - wget \ - curl \ - r-base \ - r-base-dev \ - r-recommended \ - && rm -rf /var/lib/apt/lists/* - -RUN R --version - -# install R packages included Shiny -#COPY ./scripts/install_r_packages.R . -#COPY ./scripts/packages_to_install.csv . -COPY ./scripts /opt/scripts - -RUN cd /opt/scripts/ \ - && Rscript /opt/scripts/install_r_packages.R - -#Install shiny server -#RUN apt-get update \ -# && apt-get install -y \ -# gdebi-core \ -# && rm -rf /var/lib/apt/lists/* - -RUN apt-get update \ - && apt-get install -y \ - lsb-release \ - && rm -rf /var/lib/apt/lists/* - - -RUN wget https://download3.rstudio.org/ubuntu-18.04/x86_64/shiny-server-1.5.20.1002-amd64.deb \ - && apt-get install ./shiny-server-1.5.20.1002-amd64.deb - -# copy my shiny app. -COPY ./example_proj /srv/shiny-server - -RUN cat /etc/passwd - -#RUN addgroup --gid 999 shiny \ -# && adduser --disabled-password --gecos '' --uid 999 --gid 999 shiny - -RUN chown shiny:shiny /var/lib/shiny-server -RUN mkdir -p /var/log/shiny-server -RUN chown shiny:shiny /var/log/shiny-server - -RUN sed -i "s/3838/3838 0.0.0.0/g" /etc/shiny-server/shiny-server.conf - -CMD ["shiny-server"] - -EXPOSE 3838 - -USER shiny - - -# stolen from https://github.com/qutebrowser/qutebrowser/commit/478e4de7bd1f26bebdcdc166d5369b2b5142c3e2 -# WORKAROUND for glibc 2.33 and old Docker -# See https://github.com/actions/virtual-environments/issues/2658 -# (GitLab ticket: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27557) -# Thanks to https://github.com/lxqt/lxqt-panel/pull/1562 -#RUN patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst && \ -# curl -LO "https://repo.archlinuxcn.org/x86_64/$patched_glibc" && \ -# bsdtar -C / -xvf "$patched_glibc" diff --git a/scripts/install_r_packages.R b/scripts/install_r_packages.R index 8e2eaedbdd885a1c5b4df4da76ecf9a6ceced2dd..eb01a94f8c1038c783002e939079c5c55a87e24a 100644 --- a/scripts/install_r_packages.R +++ b/scripts/install_r_packages.R @@ -5,7 +5,7 @@ #### Load file with the list of packages and the name of the deposit -packages_list <- read.csv(file = "packages_to_install.csv", header = TRUE, sep = ";", stringsAsFactors = FALSE ) +packages_list <- read.csv(file = "/opt/scripts/packages_to_install.csv", header = TRUE, sep = ";", stringsAsFactors = FALSE ) ### CRAN Packages cran_pkgs <- packages_list[which(packages_list$Deposit_name == "cran"),"Package_name"] @@ -20,4 +20,4 @@ if (length(cran_pkgs) >= 1) { if (length(bioconductor_pkgs) >= 1) { requireNamespace("BiocManager") BiocManager::install(bioconductor_pkgs, ask = FALSE) -} \ No newline at end of file +} diff --git a/scripts/install_shiny_server.sh b/scripts/install_shiny_server.sh new file mode 100755 index 0000000000000000000000000000000000000000..76a8fa7195e809ab50b9650e8bd7451f32ab7291 --- /dev/null +++ b/scripts/install_shiny_server.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +SHINY_SERVER_VERSION=${1:-${SHINY_SERVER_VERSION:-latest}} + + +if [ "$SHINY_SERVER_VERSION" = "latest" ]; then + SHINY_SERVER_VERSION=$(wget -qO- https://download3.rstudio.org/ubuntu-18.04/x86_64/VERSION) +fi + +wget --no-verbose "https://download3.rstudio.org/ubuntu-18.04/x86_64/shiny-server-${SHINY_SERVER_VERSION}-amd64.deb" -O /tmp/shiny.deb +apt install /tmp/shiny.deb +rm /tmp/shiny.deb diff --git a/scripts/packages_to_install.csv b/scripts/packages_to_install.csv index 13d2dd808ee1ab95894eaa5e4d420f8b20bf1567..9b60e0aa8985400b189e2b5fccb293a054fa985d 100644 --- a/scripts/packages_to_install.csv +++ b/scripts/packages_to_install.csv @@ -1,6 +1,3 @@ Package_name;Deposit_name shiny;cran shinythemes;cran -BiocManager;cran -biomaRt;bioconductor -ggplot2;cran \ No newline at end of file