File: Dockerfile.vtest

package info (click to toggle)
r-cran-plotly 4.9.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 26,616 kB
  • sloc: javascript: 137,775; sh: 20; makefile: 6
file content (98 lines) | stat: -rw-r--r-- 3,888 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# $ docker build -t cpsievert/plotly-vtest .
# $ docker run -e VMODE="ci" -v $(pwd):/home/plotly --privileged -p 3838:3838 cpsievert/plotly-vtest
# ------------------------------------------------------------------------------

FROM ubuntu:xenial
MAINTAINER Carson Sievert "carson@rstudio.com"

# Don't print "debconf: unable to initialize frontend: Dialog" messages
ARG DEBIAN_FRONTED=noninteractive
ARG CACHEBUST=1

# Need this to add R repo
RUN apt-get update && apt-get install -y software-properties-common apt-transport-https \
 && add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran40/" \
 && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \
 && apt-get update && apt-get install -y \
    sudo \
    git \
    vim-tiny \
    nano \
    wget \
    r-base \
    r-base-dev \
    r-recommended \
    fonts-texgyre \
    texinfo \
    locales \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    libxml2-dev \
 && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
 && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
 && locale-gen en_US.utf8 \
 && /usr/sbin/update-locale LANG=en_US.UTF-8

ENV LANG=en_US.UTF-8

# Rprofile
RUN echo 'options(\n\
  repos = c(CRAN = "https://cloud.r-project.org/"),\n\
  download.file.method = "libcurl",\n\
  Ncpus = parallel::detectCores(logical=FALSE),\n\
  shiny.host = "0.0.0.0", shiny.port = 3838\n\
)' >> /etc/R/Rprofile.site

# Update R packages and install those needed for visual testing
RUN R -e "update.packages(ask = F); invisible(lapply(list('devtools', 'roxygen2', 'testthat', 'vdiffr', 'diffobj'), install.packages, dependencies=TRUE, repos='http://cloud.r-project.org/'))"

# sf system dependencies
RUN add-apt-repository ppa:ubuntugis/ubuntugis-unstable --yes \
 && apt-get -y update \
 && apt-get install -y libudunits2-dev libproj-dev libgeos-dev libgdal-dev
 
# ragg dependencies
RUN apt-get install -y libharfbuzz-dev libfribidi-dev

# Install all plotly's dependencies
RUN R -e "install.packages('plotly', dependencies = T)"

# system dependencies related to running orca
RUN apt-get -y update \
 && apt-get install -y libgtk2.0-0 libgconf-2-4 xvfb xauth libxtst6 libxss1 libnss3 libasound2 desktop-file-utils

# google chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
    sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' && \
    apt-get update -y && \
    apt-get install -y google-chrome-stable

# Download orca binary and make it executable under xvfb
RUN mkdir -p /opt/orca \
 && cd /opt/orca \
 && wget https://github.com/plotly/orca/releases/download/v1.3.1/orca-1.3.1.AppImage \
 && chmod +x orca-1.3.1.AppImage \
 && ./orca-1.3.1.AppImage --appimage-extract \
 && rm orca-1.3.1.AppImage \
 && printf '#!/bin/bash \nargs=("$@") \nif [[ ! " ${args[@]} " =~ "--no-sandbox" ]]; then \n    args+=("--no-sandbox") \nfi \nxvfb-run --auto-servernum --server-args "-screen 0 640x480x24" /opt/orca/squashfs-root/orca "${args[@]}"' > /usr/bin/orca \
 && chmod +x /usr/bin/orca

# switch on visual testing
ENV VDIFFR=true
EXPOSE 3838

ARG CRANCACHE=1
RUN R -e "update.packages(ask=FALSE)"
RUN R -e "remotes::install_github('r-lib/vdiffr')"

# install any new dependencies, then either manage cases (the default) or run tests
# note the workaround to get docker to run a proper exit status when there are testthat errors
# https://github.com/r-lib/testthat/issues/515#issuecomment-304169376

CMD cd /home/plotly; R -e "remotes::install_deps(dependencies = T); \
if (!identical(Sys.getenv('VMODE'), 'ci')) vdiffr::manage_cases(); \
  res <- devtools::test(reporter='summary'); \
  df <- as.data.frame(res); \
  if (sum(df\$failed) > 0 || any(df\$error)) q(status=1)"