Skip to content
Snippets Groups Projects
Commit 0c089401 authored by Bryan BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

Merge branch 'install-specific-version' into 'main'

Download and install specific version

See merge request hub/rshiny-k8s!5
parents 404df4f9 1ae35045
No related branches found
No related tags found
1 merge request!5Download and install specific version
Pipeline #102029 passed
...@@ -9,21 +9,72 @@ build: ...@@ -9,21 +9,72 @@ build:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script: script:
- docker --version - docker --version
# pull the latest build on master # put both versions in a env var, to be used as tag
- docker pull "$CI_REGISTRY_IMAGE/master:latest" || true - |
# pull the latest build on this branch if [ "latest" == "${R_VERSION}" ]; then
export VERSIONS_TAG="${SHINY_SERVER_VERSION}"
else
if [ "latest" == "${SHINY_SERVER_VERSION}" ]; then
export VERSIONS_TAG="${R_VERSION}"
else
export VERSIONS_TAG="${R_VERSION}--${SHINY_SERVER_VERSION}"
fi
fi
# pull the latest build
- docker pull "$CI_REGISTRY_IMAGE:latest" || true
# pull the latest build of the targeted versions
- docker pull "$CI_REGISTRY_IMAGE:$VERSIONS_TAG" || true
# pull the latest build of the target R version in order to re-use it for the targeted SHINY_SERVER_VERSION
- docker pull "$CI_REGISTRY_IMAGE:$R_VERSION" || true
# pull the latest build of main
- docker pull "$CI_REGISTRY_IMAGE/main:latest" || true
# pull the latest build of this branch
- docker pull "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest" || true - docker pull "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest" || true
# build the image while passing commit SHA and tagging the image with it # build the image while passing commit SHA and versions, and tagging the image with them
- docker build - docker build
--build-arg CI_COMMIT_REF_SLUG --build-arg R_VERSION
--build-arg CI_COMMIT_SHA --build-arg SHINY_SERVER_VERSION
--cache-from "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest" --cache-from "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest"
--cache-from "$CI_REGISTRY_IMAGE/master:latest" --cache-from "$CI_REGISTRY_IMAGE/main:latest"
--cache-from "$CI_REGISTRY_IMAGE:$VERSIONS_TAG"
--cache-from "$CI_REGISTRY_IMAGE:$R_VERSION"
--cache-from "$CI_REGISTRY_IMAGE:latest"
--tag "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA" --tag "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA"
--tag "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest" --tag "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest"
--tag "$CI_REGISTRY_IMAGE:$VERSIONS_TAG"
--tag "$CI_REGISTRY_IMAGE:$VERSIONS_TAG--$CI_COMMIT_SHORT_SHA"
-f Dockerfile -f Dockerfile
./ ./
# push image as latest for the current branch # push image as latest for the current branch
- docker push "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest" - docker push "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest"
# push image tagged with its sha # push image tagged with its sha
- docker push "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA" - docker push "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA"
# push image tagged with its versions
- docker push "$CI_REGISTRY_IMAGE:$VERSIONS_TAG"
# push image tagged with its versions and the commit sha (debug purpose)
- docker push "$CI_REGISTRY_IMAGE:$VERSIONS_TAG--$CI_COMMIT_SHORT_SHA"
parallel:
matrix:
- R_VERSION: ["3.6.3", "4.2.3", "latest"]
SHINY_SERVER_VERSION: ["latest"]
build-example:
stage: build
needs: ["build"]
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
# pull the latest example of rshiny-k8s image
- docker pull "$CI_REGISTRY_IMAGE/example:example" || true
# build the image while passing commit SHA and versions, and tagging the image with them
- docker build
--cache-from "$CI_REGISTRY_IMAGE/example:latest"
--tag "$CI_REGISTRY_IMAGE/example:latest"
--tag "$CI_REGISTRY_IMAGE/example:$CI_COMMIT_SHORT_SHA"
-f example.Dockerfile
./
# push image tagged as example
- docker push "$CI_REGISTRY_IMAGE/example:latest"
# push image tagged as example with its commit sha (debug purpose)
- docker push "$CI_REGISTRY_IMAGE/example:$CI_COMMIT_SHORT_SHA"
...@@ -3,7 +3,8 @@ FROM ubuntu:focal ...@@ -3,7 +3,8 @@ FROM ubuntu:focal
# define geographic location during R installation # define geographic location during R installation
ENV TZ=Etc/UTC ENV TZ=Etc/UTC
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
ARG SHINY_SERVER_VERSION ARG SHINY_SERVER_VERSION=latest
ARG R_VERSION=latest
EXPOSE 3838 EXPOSE 3838
CMD ["shiny-server"] CMD ["shiny-server"]
...@@ -14,15 +15,30 @@ RUN apt-get update \ ...@@ -14,15 +15,30 @@ RUN apt-get update \
nano \ nano \
wget \ wget \
curl \ curl \
r-base \
r-base-dev \
r-recommended \
lsb-release \ lsb-release \
&& rm -rf /var/lib/apt/lists/* \ libcurl4-openssl-dev \
&& R --version gcc \
gfortran \
g++ \
libreadline-dev \
zlib1g-dev \
libbz2-dev \
liblzma-dev \
libpcre2-dev \
libcairo-dev \
libpng-dev \
libicu-dev \
make \
libtiff-dev \
&& rm -rf /var/lib/apt/lists/*
COPY ./scripts /opt/scripts COPY ./scripts /opt/scripts
#install R, along with its dependencies
RUN /opt/scripts/install_r_cran.sh
# test R in another layer
RUN R -q -e "sessionInfo()"
# Install R packages included Shiny, then install shiny server # Install R packages included Shiny, then install shiny server
RUN Rscript /opt/scripts/install_r_packages.R RUN Rscript /opt/scripts/install_r_packages.R
RUN /opt/scripts/install_shiny_server.sh RUN /opt/scripts/install_shiny_server.sh
...@@ -30,9 +46,6 @@ RUN /opt/scripts/install_shiny_server.sh ...@@ -30,9 +46,6 @@ RUN /opt/scripts/install_shiny_server.sh
# allows trafic from all ips # allows trafic from all ips
RUN sed -i "s/3838/3838 0.0.0.0/g" /etc/shiny-server/shiny-server.conf 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
#RUN chown shiny:shiny /var/lib/shiny-server #RUN chown shiny:shiny /var/lib/shiny-server
RUN mkdir -p /var/log/shiny-server \ RUN mkdir -p /var/log/shiny-server \
&& chown shiny:shiny /var/log/shiny-server && chown shiny:shiny /var/log/shiny-server
......
apiVersion: v1
kind: Pod
metadata:
name: example
spec:
containers:
- name: example
image: registry-gitlab.pasteur.fr/hub/rshiny-k8s/example:latest
securityContext:
runAsGroup: 999
runAsUser: 999
ports:
- name: http
containerPort: 3838
protocol: TCP
# FROM registry-gitlab.pasteur.fr/hub/rshiny-k8s:4.2.3--1.5.21.1006
# FROM registry-gitlab.pasteur.fr/hub/rshiny-k8s:1.5.21.1006
# FROM registry-gitlab.pasteur.fr/hub/rshiny-k8s:4.2.3
FROM registry-gitlab.pasteur.fr/hub/rshiny-k8s:latest
# Copy your dependencies, destination filename must be "packages_to_install.csv"
COPY ./example_proj/my_packages_to_install.csv /opt/scripts/packages_to_install.csv
# Install R packages
RUN Rscript /opt/scripts/install_r_packages.R
# Copy you shiny app
COPY ./example_proj /srv/shiny-server
Package_name;Deposit_name
shiny;cran
shinythemes;cran
#!/bin/bash
set -e
R_VERSION=${1:-${R_VERSION:-latest}}
R_HOME=${R_HOME:-"/usr/local/lib/R"}
CRAN="https://cran.r-project.org"
cd /tmp
if [ ! -f "R-${R_VERSION}.tar.gz" ]; then
echo "/tmp/R-${R_VERSION}.tar.gz is missing, downloading it"
if [ "$R_VERSION" = "latest" ]; then
curl -O https://cran.r-project.org/src/base/R-latest.tar.gz
else
curl -O https://cran.rstudio.com/src/base/R-${R_VERSION::1}/R-${R_VERSION}.tar.gz
fi
fi
tar -xzvf R-${R_VERSION}.tar.gz
# go in uncompressed dir, when using R_VERSION="R-latest",
# the dir is not R-latest, but the one with the version
cd R-*/
# Configure the sources, check dependencies
./configure \
--enable-R-shlib \
--enable-memory-profiling \
--with-blas \
--with-lapack \
--with-x=no \
--with-cairo=yes \
--enable-java=no
make
make install
echo "Install completed, testing R"
R -q -e "sessionInfo()" || exit 1
echo "R found in path, good to go!"
make clean
rm /tmp/R-${R_VERSION}.tar.gz
cat <<EOF >"${R_HOME}/etc/Rprofile.site"
options(
repos = c( CRAN = '${CRAN}'),
download.file.method = 'libcurl'
)
EOF
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment