Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a working Gitpod set-up #17

Closed
MiguelRodo opened this issue May 2, 2023 · 6 comments
Closed

Add a working Gitpod set-up #17

MiguelRodo opened this issue May 2, 2023 · 6 comments

Comments

@MiguelRodo
Copy link
Owner

.gitpod.yml in root directory:

# List the start up tasks. Learn more: https://www.gitpod.io/docs/configure/workspaces/tasks
image:
  file: .gitpod.Dockerfile

tasks:
  - name: Script Task
    init: echo 'init script' # runs during prebuild => https://www.gitpod.io/docs/configure/projects/prebuilds
    command: echo 'start script'

# List the ports to expose. Learn more: https://www.gitpod.io/docs/configure/workspaces/ports
ports:
  - name: Frontend
    description: Port 3000 for the frontend
    port: 3000
    onOpen: open-preview

# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart

.gitpod.Dockerfile in root directory:

FROM rocker/verse:4.2.3

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
    && apt-get upgrade -y \
    && apt-get install -y apt-utils \
        gdebi-core \
        openssh-client \
        gnupg2 \
        dirmngr \
        iproute2 \
        procps \
        lsof \
        htop \
        net-tools \
        psmisc \
        curl \
        wget \
        rsync \
        ca-certificates \
        unzip \
        zip \
        nano \
        vim-tiny \
        less \
        jq \
        lsb-release \
        apt-transport-https \
        dialog \
        libc6 \
        libgcc1 \
        libkrb5-3 \
        libgssapi-krb5-2 \
        libicu[0-9][0-9] \
        libicu-dev \
        libstdc++6 \
        zlib1g \
        locales \
        sudo \
        ncdu \
        man-db \
        strace \
        manpages \
        manpages-dev \
        librdf0-dev \
        init-system-helpers

RUN apt-get -y install libsecret-1-0 \
    && apt-get -y install \
        python3-pip \
        libgit2-dev \
        libcurl4-openssl-dev \
        libssl-dev \
        libxml2-dev \
        libxt-dev \
        libfontconfig1-dev \
        libcairo2-dev

RUN apt-get -y install \
      libgeos-dev \
      libgdal-dev \
      libproj-dev \
      libudunits2-dev \
      libsodium-dev \
      pandoc \
      openjdk-8-jdk \
      openjdk-8-jre \
      cargo \
      libfreetype6-dev \
      libclang-dev \
      fonts-roboto \
        && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*

RUN python3 -m pip --no-cache-dir install radian \ 
    && echo "options(radian.editing_mode = 'vi')" > ~/.radian_profile \
    && echo "options(radian.auto_match = FALSE)" >> ~/.radian_profile

RUN curl -LO https://quarto.org/download/latest/quarto-linux-amd64.deb \
    && gdebi -n quarto-linux-amd64.deb

RUN curl -LO https://quarto.org/download/latest/quarto-linux-amd64.deb \
    && gdebi -n quarto-linux-amd64.deb \
    && wget -qO \
    "/usr/local/bin/code-server" \
    "https://aka.ms/vscode-server-launcher/x86_64-unknown-linux-gnu" \
    && chmod a+x "/usr/local/bin/code-server"

ENV RENV_VERSION 0.17.3

RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))"
RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')"

WORKDIR /project
COPY renv.lock renv.lock

ENV RENV_PATHS_LIBRARY renv/library

COPY scripts/R/dev.R scripts/R/dev.R
COPY scripts/R/hpc_renv_setup.R scripts/R/hpc_renv_setup.R

RUN R -e "renv::install('pak')"
RUN R -e "options(renv.config.pak.enabled = TRUE); renv::restore(); options(renv.config.pak.enabled = FALSE)"
@MiguelRodo
Copy link
Owner Author

Trying to use my HPC settings for renv as it seems to not be restoring properly:

FROM rocker/verse:4.2.3

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
    && apt-get upgrade -y \
    && apt-get install -y apt-utils \
        gdebi-core \
        openssh-client \
        gnupg2 \
        dirmngr \
        iproute2 \
        procps \
        lsof \
        htop \
        net-tools \
        psmisc \
        curl \
        wget \
        rsync \
        ca-certificates \
        unzip \
        zip \
        nano \
        vim-tiny \
        less \
        jq \
        lsb-release \
        apt-transport-https \
        dialog \
        libc6 \
        libgcc1 \
        libkrb5-3 \
        libgssapi-krb5-2 \
        libicu[0-9][0-9] \
        libicu-dev \
        libstdc++6 \
        zlib1g \
        locales \
        sudo \
        ncdu \
        man-db \
        strace \
        manpages \
        manpages-dev \
        librdf0-dev \
        init-system-helpers

RUN apt-get -y install libsecret-1-0 \
    && apt-get -y install \
        python3-pip \
        libgit2-dev \
        libcurl4-openssl-dev \
        libssl-dev \
        libxml2-dev \
        libxt-dev \
        libfontconfig1-dev \
        libcairo2-dev

RUN apt-get -y install \
      libgeos-dev \
      libgdal-dev \
      libproj-dev \
      libudunits2-dev \
      libsodium-dev \
      pandoc \
      openjdk-8-jdk \
      openjdk-8-jre \
      cargo \
      libfreetype6-dev \
      libclang-dev \
      fonts-roboto \
        && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*

RUN python3 -m pip --no-cache-dir install radian \ 
    && echo "options(radian.editing_mode = 'vi')" > ~/.radian_profile \
    && echo "options(radian.auto_match = FALSE)" >> ~/.radian_profile

RUN curl -LO https://quarto.org/download/latest/quarto-linux-amd64.deb \
    && gdebi -n quarto-linux-amd64.deb

RUN curl -LO https://quarto.org/download/latest/quarto-linux-amd64.deb \
    && gdebi -n quarto-linux-amd64.deb \
    && wget -qO \
    "/usr/local/bin/code-server" \
    "https://aka.ms/vscode-server-launcher/x86_64-unknown-linux-gnu" \
    && chmod a+x "/usr/local/bin/code-server"

ENV RENV_VERSION 0.17.3

RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))"
RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')"

WORKDIR /project
COPY renv.lock renv.lock

ENV RENV_PATHS_CACHE .local/R/lib/renv
ENV RENV_PATHS_ROOT .cache/R/renv
ENV RENV_PATHS_LIBRARY_ROOT .cache/R/renv
ENV RENV_PATHS_LIBRARY .cache/R/renv
ENV RENV_PATHS_PREFIX_AUTO TRUE

COPY scripts/R/dev.R scripts/R/dev.R
COPY scripts/R/hpc_renv_setup.R scripts/R/hpc_renv_setup.R

RUN R -e "renv::install('pak')"
RUN R -e "options(renv.config.pak.enabled = TRUE); renv::restore(); options(renv.config.pak.enabled = FALSE)"

@MiguelRodo
Copy link
Owner Author

I could try use an updated code cli as well:
https://code.visualstudio.com/docs/remote/tunnels#_getting-started

@MiguelRodo
Copy link
Owner Author

So, renv works with the following library locations:
image
RENV_PATHS_CACHE is "/home/gitpod/renv;/renv" and .libPaths() is " "/home/gitpod/.cache/R/renv/library/Prac23RodoHonsMultFAMemo-addf8176/R-4.2/x86_64-pc-linux-gnu" "/home/gitpod/.cache/R/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/25ebdc09"

@MiguelRodo
Copy link
Owner Author

MiguelRodo commented Jun 7, 2023

Okay, so I can do this as follows:

  • Open a GitPod template that has apptainer
    • Can just use this repo as a template
      • But for tidiness, really should do another one
  • Download the relevant sif container
  • Either run apptainer exec <path/to/sif> code-server tunnel --accept-server-license-terms OR
  • Run apptainer exec </path/to/sif> Rscript -e "projr::projr_restore(); projr::projr_build_dev()

I totally think we should avoid the whole building R thing. It takes a while and it's not even always the same container.

@MiguelRodo
Copy link
Owner Author

Deprecated in favour of #24

@MiguelRodo MiguelRodo closed this as not planned Won't fix, can't repro, duplicate, stale Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant