Skip to content

Commit baac010

Browse files
committed
Adding binder
1 parent caee6d0 commit baac010

File tree

7 files changed

+2305
-15
lines changed

7 files changed

+2305
-15
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build Binder
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
workflow_dispatch: {}
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
actions: write
15+
packages: write
16+
17+
jobs:
18+
build-docker:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Free disk space
24+
run: |
25+
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true
26+
sudo rm -rf \
27+
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
28+
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
29+
/usr/lib/jvm || true
30+
sudo apt install aptitude -y >/dev/null 2>&1
31+
sudo aptitude purge aria2 ansible azure-cli shellcheck rpm xorriso zsync \
32+
esl-erlang firefox gfortran-8 gfortran-9 google-chrome-stable \
33+
google-cloud-sdk imagemagick \
34+
libmagickcore-dev libmagickwand-dev libmagic-dev ant ant-optional kubectl \
35+
mercurial apt-transport-https mono-complete libmysqlclient \
36+
unixodbc-dev yarn chrpath libssl-dev libxft-dev \
37+
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev \
38+
snmp pollinate libpq-dev postgresql-client powershell ruby-full \
39+
sphinxsearch subversion mongodb-org azure-cli microsoft-edge-stable \
40+
-y -f >/dev/null 2>&1
41+
sudo aptitude purge google-cloud-sdk -f -y >/dev/null 2>&1
42+
sudo aptitude purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true
43+
sudo apt purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true
44+
sudo aptitude purge '~n ^mysql' -f -y >/dev/null 2>&1
45+
sudo aptitude purge '~n ^php' -f -y >/dev/null 2>&1
46+
sudo aptitude purge '~n ^dotnet' -f -y >/dev/null 2>&1
47+
sudo swapoff -a
48+
sudo rm -f /swapfile
49+
sudo apt-get remove -y azure-cli mono-devel
50+
sudo apt-get autoremove -y
51+
sudo apt-get clean
52+
sudo apt-get autoremove -y >/dev/null 2>&1
53+
sudo apt-get autoclean -y >/dev/null 2>&1
54+
sudo rm -rf /usr/share/dotnet
55+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
56+
df -h
57+
- name: Set up QEMU
58+
uses: docker/setup-qemu-action@v3
59+
- name: Set up Docker Buildx
60+
uses: docker/setup-buildx-action@v3
61+
- name: Login to GitHub Package Registry
62+
uses: docker/login-action@v2
63+
with:
64+
registry: ghcr.io
65+
username: ${{ github.repository_owner }}
66+
password: ${{ secrets.GHCR_TOKEN }}
67+
- name: Docker push binder
68+
run: |
69+
docker compose build binder
70+
docker compose push binder

binder/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM ghcr.io/plant-food-research-open/binder-rpipelines:0.1.0

docker-compose.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
version: "3.9"
22

33
services:
4-
54
postgres:
65
image: postgres:15.3-bullseye
76
restart: always
@@ -66,7 +65,7 @@ services:
6665
- 8088:8088
6766
volumes:
6867
- superset-data:/app/superset_home
69-
68+
7069
shiny:
7170
image: ghcr.io/plant-food-research-open/shiny-rpipelines:${APP_VERSION:-latest}
7271
build:
@@ -96,6 +95,24 @@ services:
9695
stop_grace_period: 10s
9796
ports:
9897
- 8787:8787
98+
environment:
99+
USER: user
100+
PASSWORD: password
101+
ROOT: "TRUE"
102+
DISABLE_AUTH: "TRUE"
103+
command: >
104+
rserver --server-user rstudio --www-port 8787 --server-daemonize=0
105+
106+
binder:
107+
image: ghcr.io/plant-food-research-open/binder-rpipelines:${APP_VERSION:-latest}
108+
build:
109+
context: .
110+
dockerfile: ./dockerfiles/binder/Dockerfile.${APP_VERSION}
111+
args:
112+
BUILD_DATE: date -u +'%Y-%m-%dT%H:%M:%SZ'
113+
APP_VERSION: ${APP_VERSION:-latest}
114+
tags:
115+
- ghcr.io/plant-food-research-open/binder-rpipelines:latest
99116

100117
mlflow:
101118
image: ghcr.io/plant-food-research-open/mlflow-rpipelines:${APP_VERSION:-latest}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
FROM rocker/binder:4.4.1 AS base
2+
3+
ARG BUILD_DATE
4+
5+
ARG APP_VERSION
6+
7+
8+
9+
LABEL org.label-schema.build-date=$BUILD_DATE
10+
11+
LABEL version=$APP_VERSION
12+
13+
WORKDIR /app
14+
15+
USER root
16+
17+
COPY README.md README.md
18+
19+
ENV DEBIAN_FRONTEND=noninteractive \
20+
RENV_PATHS_ROOT=/app/renv \
21+
RENV_PATHS_LIBRARY=/app/renv/library \
22+
RENV_PATHS_CACHE=/app/renv/.cache \
23+
RENV_CONFIG_REPOS_OVERRIDE=https://cloud.r-project.org \
24+
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/bin/java
25+
26+
RUN apt-get update \
27+
&& apt-get install -y --no-install-recommends openjdk-17-jdk pandoc libsodium-dev graphviz \
28+
libglpk-dev cmake libnng-dev libmbedtls-dev openssh-client liblzma-dev libpq-dev libcurl4-openssl-dev \
29+
libbz2-dev software-properties-common build-essential libmagic-dev libmagick++-dev curl g++ make \
30+
libharfbuzz-dev libfribidi-dev \
31+
&& apt-get clean \
32+
&& rm -rf /var/lib/apt/lists/* \
33+
&& rm -rf /tmp/downloaded_packages \
34+
&& install2.r -e -n -1 --skipinstalled remotes \
35+
&& R -e 'remotes::install_version("renv","1.0.7", repos = "https://cran.rstudio.com/")' \
36+
&& R -e 'remotes::install_version("pak","0.7.2", repos = "https://cran.rstudio.com/")' \
37+
&& R CMD javareconf -e
38+
39+
FROM base AS r_builder
40+
41+
COPY renv.lock .renvignore .Rprofile ./
42+
43+
COPY renv /app/renv
44+
45+
RUN mkdir -p $RENV_PATHS_LIBRARY \
46+
&& mkdir -p $RENV_PATHS_CACHE \
47+
&& R -e \
48+
"options(renv.config.pak.enabled=TRUE, renv.consent=TRUE); renv::restore()"
49+
50+
FROM base AS python_builder
51+
52+
ENV POETRY_NO_INTERACTION=1 \
53+
POETRY_VIRTUALENVS_IN_PROJECT=1 \
54+
POETRY_VIRTUALENVS_CREATE=1 \
55+
POETRY_CACHE_DIR=/tmp/poetry_cache \
56+
PATH="/root/.local/bin:$PATH"
57+
58+
COPY pyproject.toml poetry.lock ./
59+
60+
RUN curl -sSL https://install.python-poetry.org | python3 -\
61+
&& poetry install --no-root --with dev \
62+
&& rm -rf $POETRY_CACHE_DIR \
63+
&& curl -sSL https://install.python-poetry.org | python3 - --uninstall
64+
65+
FROM base AS runtime
66+
67+
ENV R_LIBS=/app/renv/library/R-4.4/x86_64-pc-linux-gnu \
68+
R_LIBS_SITE=/app/renv/library/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu \
69+
VIRTUAL_ENV=/app/.venv \
70+
PATH="/app/.venv/bin:$PATH"
71+
72+
COPY --chown=${NB_USER}:${NB_USER} ./app .
73+
74+
COPY --from=r_builder --chown=${NB_USER}:${NB_USER} /app .
75+
76+
COPY --from=python_builder --chown=${NB_USER}:${NB_USER} ${VIRTUAL_ENV} ${VIRTUAL_ENV}
77+
78+
RUN chown -R ${NB_USER}:${NB_USER} /app \
79+
&& chmod -R 755 /app \
80+
&& R -e "cmdstanr::install_cmdstan()" \
81+
&& echo '.libPaths(c("/app/renv/library/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu", .libPaths()))' \
82+
>> /usr/local/lib/R/etc/Rprofile.site
83+
84+
USER ${NB_USER}
85+
86+
EXPOSE 8787 8787

dockerfiles/rstudio/Dockerfile.0.1.0

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ RUN apt-get update \
3232
&& install2.r -e -n -1 --skipinstalled remotes \
3333
&& R -e 'remotes::install_version("renv","1.0.7", repos = "https://cran.rstudio.com/")' \
3434
&& R -e 'remotes::install_version("pak","0.7.2", repos = "https://cran.rstudio.com/")' \
35-
&& R CMD javareconf -e \
36-
&& adduser shiny
35+
&& R CMD javareconf -e
3736

3837
FROM base AS r_builder
3938

@@ -64,21 +63,20 @@ RUN curl -sSL https://install.python-poetry.org | python3 -\
6463
FROM base AS runtime
6564

6665
ENV R_LIBS=/app/renv/library/R-4.4/x86_64-pc-linux-gnu \
66+
R_LIBS_SITE=/app/renv/library/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu \
6767
VIRTUAL_ENV=/app/.venv \
6868
PATH="/app/.venv/bin:$PATH"
6969

70-
COPY --chown=shiny:shiny ./app .
70+
COPY --chown=rstudio:rstudio ./app .
7171

72-
COPY --from=r_builder --chown=shiny:shiny /app .
72+
COPY --from=r_builder --chown=rstudio:rstudio /app .
7373

74-
COPY --from=python_builder --chown=shiny:shiny ${VIRTUAL_ENV} ${VIRTUAL_ENV}
74+
COPY --from=python_builder --chown=rstudio:rstudio ${VIRTUAL_ENV} ${VIRTUAL_ENV}
7575

76-
RUN chown -R shiny:shiny /app \
76+
RUN chown -R rstudio:rstudio /app \
7777
&& chmod -R 755 /app \
78-
&& R -e "cmdstanr::install_cmdstan()"
78+
&& R -e "cmdstanr::install_cmdstan()" \
79+
&& echo '.libPaths(c("/app/renv/library/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu", .libPaths()))' \
80+
>> /usr/local/lib/R/etc/Rprofile.site
7981

80-
EXPOSE 3838
81-
82-
EXPOSE 8088
83-
84-
CMD ["R", "-e", "shiny::runApp('/app', launch.browser = FALSE, host = '0.0.0.0', port = 3838)"]
82+
EXPOSE 8787 8787

0 commit comments

Comments
 (0)