Skip to content

Commit

Permalink
feat: add vscodium images for new amalthea (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
olevski authored Nov 27, 2024
1 parent a51e125 commit d1466a2
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 2 deletions.
232 changes: 231 additions & 1 deletion .github/workflows/build-and-push-to-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
- docker/julia/Dockerfile
- docker/batch/Dockerfile
- docker/qgis/Dockerfile
- docker/vscode/base.Dockerfile
- docker/vscode/conda.Dockerfile
- docker/vscode/poetry.Dockerfile
- docker/vscode/R.Dockerfile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -414,7 +418,7 @@ jobs:
PYTHON_VERSION: "3.11"
steps:
- name: Docker Login
uses: Azure/docker-login@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.RENKU_DOCKER_USERNAME }}
password: ${{ secrets.RENKU_DOCKER_PASSWORD }}
Expand Down Expand Up @@ -698,3 +702,229 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
provenance: false

build-vscode-base:
needs: lint
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
include:
- BASE_IMAGE: ubuntu:24.04
BASE_IMAGE_TAG: ubuntu
LATEST: true
steps:
- name: Docker Login
uses: docker/login-action@v3
with:
username: ${{ secrets.RENKU_DOCKER_USERNAME }}
password: ${{ secrets.RENKU_DOCKER_PASSWORD }}
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_PREFIX }}-vscode
tags: |
type=sha,prefix=${{ matrix.BASE_IMAGE_TAG }}-
type=semver,pattern={{version}},prefix=${{ matrix.BASE_IMAGE_TAG }}-
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' && matrix.LATEST }}
- name: Build and export
uses: docker/build-push-action@v6
with:
build-args: |
BASE_IMAGE=${{ matrix.BASE_IMAGE }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: docker/vscode
file: docker/vscode/base.Dockerfile
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: ${{ steps.meta.outputs.tags }}
provenance: false

build-vscode-conda:
needs: build-vscode-base
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
include:
- PYTHON_VERSION: 3.12.7
BASE_IMAGE_TAG: ubuntu
LATEST: true
- PYTHON_VERSION: 3.11.10
BASE_IMAGE_TAG: ubuntu
LATEST: false
- PYTHON_VERSION: 3.10.15
BASE_IMAGE_TAG: ubuntu
LATEST: false
steps:
- name: Docker Login
uses: docker/login-action@v3
with:
username: ${{ secrets.RENKU_DOCKER_USERNAME }}
password: ${{ secrets.RENKU_DOCKER_PASSWORD }}
- uses: actions/checkout@v4
- name: Set outputs
id: vars
run: |
sha_short=$(git rev-parse --short HEAD)
echo "sha_short=$sha_short" >> $GITHUB_OUTPUT
echo "renku_base=${DOCKER_PREFIX}-vscode:${{ matrix.BASE_IMAGE_TAG }}-${sha_short}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_PREFIX }}-vscode-python
tags: |
type=sha,prefix=py-${{ matrix.PYTHON_VERSION }}-
type=semver,pattern={{version}},prefix=py-${{ matrix.PYTHON_VERSION }}-
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' && matrix.LATEST }}
- name: Build and export
uses: docker/build-push-action@v6
with:
build-args: |
BASE_IMAGE=${{ steps.vars.outputs.renku_base }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: docker/vscode
file: docker/vscode/conda.Dockerfile
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: ${{ steps.meta.outputs.tags }}
provenance: false

build-vscode-poetry:
needs: build-vscode-base
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
include:
- PYTHON_VERSION: 3.12.7
BASE_IMAGE_TAG: ubuntu
PYENV_VERSION: v2.4.17
POETRY_VERSION: 1.8.4
LATEST: true
- PYTHON_VERSION: 3.11.10
BASE_IMAGE_TAG: ubuntu
PYENV_VERSION: v2.4.17
POETRY_VERSION: 1.8.4
LATEST: false
- PYTHON_VERSION: 3.10.15
BASE_IMAGE_TAG: ubuntu
PYENV_VERSION: v2.4.17
POETRY_VERSION: 1.8.4
LATEST: false
steps:
- name: Docker Login
uses: docker/login-action@v3
with:
username: ${{ secrets.RENKU_DOCKER_USERNAME }}
password: ${{ secrets.RENKU_DOCKER_PASSWORD }}
- uses: actions/checkout@v4
- name: Set outputs
id: vars
run: |
sha_short=$(git rev-parse --short HEAD)
echo "sha_short=$sha_short" >> $GITHUB_OUTPUT
echo "renku_base=${DOCKER_PREFIX}-vscode:${{ matrix.BASE_IMAGE_TAG }}-${sha_short}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_PREFIX }}-vscode-poetry
tags: |
type=sha,prefix=py-${{ matrix.PYTHON_VERSION }}-
type=semver,pattern={{version}},prefix=py-${{ matrix.PYTHON_VERSION }}-
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' && matrix.LATEST }}
- name: Build and export
uses: docker/build-push-action@v6
with:
build-args: |
BASE_IMAGE=${{ steps.vars.outputs.renku_base }}
PYTHON_VERSION=${{ matrix.PYTHON_VERSION }}
POETRY_VERSION=${{ matrix.POETRY_VERSION }}
PYENV_VERSION=${{ matrix.PYENV_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: docker/vscode
file: docker/vscode/poetry.Dockerfile
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: ${{ steps.meta.outputs.tags }}
provenance: false

build-vscode-r:
needs: build-vscode-base
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
include:
- R_VERSION: 4.4.2
BASE_IMAGE_TAG: ubuntu
LATEST: true
- R_VERSION: 4.3.3
BASE_IMAGE_TAG: ubuntu
LATEST: false
- R_VERSION: 4.2.3
BASE_IMAGE_TAG: ubuntu
LATEST: false
steps:
- name: Docker Login
uses: docker/login-action@v3
with:
username: ${{ secrets.RENKU_DOCKER_USERNAME }}
password: ${{ secrets.RENKU_DOCKER_PASSWORD }}
- uses: actions/checkout@v4
- name: Set outputs
id: vars
run: |
sha_short=$(git rev-parse --short HEAD)
echo "sha_short=$sha_short" >> $GITHUB_OUTPUT
echo "renku_base=${DOCKER_PREFIX}-vscode:${{ matrix.BASE_IMAGE_TAG }}-${sha_short}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_PREFIX }}-vscode-r
tags: |
type=sha,prefix=r-${{ matrix.R_VERSION }}-
type=semver,pattern={{version}},prefix=r-${{ matrix.R_VERSION }}-
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' && matrix.LATEST }}
- name: Build and export
uses: docker/build-push-action@v6
with:
build-args: |
BASE_IMAGE=${{ steps.vars.outputs.renku_base }}
R_VERSION=${{ matrix.R_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: docker/vscode
file: docker/vscode/R.Dockerfile
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: ${{ steps.meta.outputs.tags }}
provenance: false
3 changes: 2 additions & 1 deletion docker/py/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ jupyter() {
if [[ -v RENKU_BASE_URL_PATH ]]; then
"$@" --ServerApp.port=8888 --ServerApp.base_url="$RENKU_BASE_URL_PATH" \
--ServerApp.token="" --ServerApp.password="" --ServerApp.allow_remote_access=true \
--ContentsManager.allow_hidden=true --ServerApp.allow_origin=*
--ContentsManager.allow_hidden=true --ServerApp.allow_origin=* \
--ServerApp.root_dir="${HOME}/work"
fi

# run the command
Expand Down
29 changes: 29 additions & 0 deletions docker/vscode/R.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG BASE_IMAGE=renku/renkulab-vscode:latest
FROM $BASE_IMAGE
ARG R_VERSION=4.4.2
ARG SESSION_USER=vscode
ARG WORKDIR=/home/${SESSION_USER}
ARG MOUNTDIR=${WORKDIR}/work

SHELL [ "/bin/bash", "-c", "-o", "pipefail" ]
USER root
# From https://docs.posit.co/resources/install-r.html
RUN curl -O https://cdn.rstudio.com/r/ubuntu-2404/pkgs/r-${R_VERSION}_1_amd64.deb \
&& apt-get update \
&& apt-get install -y --no-install-recommends ./r-${R_VERSION}_1_amd64.deb \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf ./r-${R_VERSION}_1_amd64.deb \
&& ln -s /opt/R/${R_VERSION}/bin/R /usr/local/bin/R \
&& ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/local/bin/Rscript

USER ${SESSION_USER}
ENV __MOUNTDIR__=${MOUNTDIR}
WORKDIR ${WORKDIR}
# The .Renviron changes allow R to install packages in the work directory
# See https://www.r-bloggers.com/2020/10/customizing-your-package-library-location/
# The .Rprofile changes allow R to be able to use precompiled packages
# See https://packagemanager.posit.co/client/#/repos/cran/setup
RUN printf "\nR_LIBS_SITE=\"%s/.rlibs\"\n" "${MOUNTDIR}" >> /home/${SESSION_USER}/.Renviron \
&& printf "\noptions(repos = c(CRAN = \"https://packagemanager.posit.co/cran/__linux__/noble/latest\"))\n" >> /home/${SESSION_USER}/.Rprofile
ENTRYPOINT ["tini", "--", "sh", "-c"]
CMD ["mkdir -p ${__MOUNTDIR__}/.rlibs && bash /entrypoint.sh"]
23 changes: 23 additions & 0 deletions docker/vscode/base.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG BASE_IMAGE=ubuntu:24.04
FROM $BASE_IMAGE
ARG VSCODIUM_VERSION=1.95.2.24313
ARG SESSION_USER=vscode
ARG WORKDIR=/home/${SESSION_USER}
ARG MOUNTDIR=${WORKDIR}/work
SHELL [ "/bin/bash", "-c", "-o", "pipefail" ]
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates curl tini build-essential git git-lfs && \
mkdir -p /codium-server && \
curl -L https://github.com/VSCodium/vscodium/releases/download/${VSCODIUM_VERSION}/vscodium-reh-web-linux-x64-${VSCODIUM_VERSION}.tar.gz | tar -xz -C /codium-server && \
rm -rf /var/lib/apt/lists/*
RUN useradd -m -s /bin/bash ${SESSION_USER}
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8

USER ${SESSION_USER}
COPY entrypoint.sh /entrypoint.sh
WORKDIR ${WORKDIR}
# We are setting this to a weird double underscore name to avoid collisions with user-set vars
ENV __MOUNTDIR__=${MOUNTDIR}
RUN mkdir -p ${MOUNTDIR}
ENTRYPOINT ["tini", "--", "/bin/bash", "/entrypoint.sh"]
29 changes: 29 additions & 0 deletions docker/vscode/conda.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG BASE_IMAGE=renku/renkulab-vscode:latest
FROM $BASE_IMAGE
ARG MICROMAMBA_VERSION=2.0.2-2
ARG MAMBA_VERSION=1.5.9
ARG CONDA_VERSION=24.9.2
ARG PYTHON_VERSION=3.12.7
ARG OS=linux
ARG ARCH=64
ARG SESSION_USER=vscode
ARG WORKDIR=/home/${SESSION_USER}
ARG MOUNTDIR=${WORKDIR}/work
ARG VENVS_PATH=${MOUNTDIR}/.venvs
ENV __VENVS_PATH__=${VENVS_PATH}
ENV __PYTHON_VERSION__=${PYTHON_VERSION}
ENV __MAMBA_VERSION__=${MAMBA_VERSION}
ENV __CONDA_VERSION__=${CONDA_VERSION}
SHELL [ "/bin/bash", "-c", "-o", "pipefail" ]
USER root
RUN apt-get update && \
apt-get install -y curl --no-install-recommends && \
curl -L "https://github.com/mamba-org/micromamba-releases/releases/download/${MICROMAMBA_VERSION}/micromamba-${OS}-${ARCH}" -o /usr/local/bin/micromamba && \
chmod a+x /usr/local/bin/micromamba && \
rm -rf /var/lib/apt/lists/*

USER ${SESSION_USER}
WORKDIR ${WORKDIR}
ENV __MOUNTDIR__=${MOUNTDIR}
ENTRYPOINT ["tini", "--", "sh", "-c"]
CMD ["set -ex && micromamba install --yes --root-prefix=${__VENVS_PATH__} --prefix=${__VENVS_PATH__} python=${__PYTHON_VERSION__} mamba=${__MAMBA_VERSION__} conda=${__CONDA_VERSION__} && ${__VENVS_PATH__}/bin/mamba init && ${__VENVS_PATH__}/bin/conda config --add channels conda-forge && ${__VENVS_PATH__}/bin/conda config --set channel_priority strict && ${__VENVS_PATH__}/bin/conda config --remove channels defaults && bash /entrypoint.sh"]
12 changes: 12 additions & 0 deletions docker/vscode/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set -ex
MOUNTDIR=${__MOUNTDIR__}
mkdir -p "${MOUNTDIR}/.vscode/extensions"
/codium-server/bin/codium-server \
--server-base-path "$RENKU_BASE_URL_PATH/" \
--without-connection-token \
--host 0.0.0.0 \
--port 8888 \
--extensions-dir "${MOUNTDIR}/.vscode/extensions" \
--accept-server-license-terms \
--telemetry-level off \
--server-data-dir "${MOUNTDIR}/.vscode"
26 changes: 26 additions & 0 deletions docker/vscode/poetry.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ARG BASE_IMAGE=renku/renkulab-vscode:latest
FROM $BASE_IMAGE
ARG PYENV_VERSION=v2.4.17
ARG PYTHON_VERSION=3.12.7
# Empty string for poetry version means the latest version
ARG POETRY_VERSION=""
ARG SESSION_USER=vscode
ARG WORKDIR=/home/${SESSION_USER}
ARG MOUNTDIR=${WORKDIR}/work
ARG VENVS_PATH=${MOUNTDIR}/.venvs
SHELL [ "/bin/bash", "-c", "-o", "pipefail" ]
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends curl libz-dev libreadline-dev libncurses-dev libsqlite3-dev libssl-dev liblzma-dev libgdbm-dev libbz2-dev libffi-dev && \
mkdir -p /python-build && \
curl -L https://github.com/pyenv/pyenv/archive/refs/tags/${PYENV_VERSION}.tar.gz | tar -xz -C /python-build && \
/bin/sh /python-build/*/plugins/python-build/install.sh && \
python-build ${PYTHON_VERSION} /usr/local && \
rm -rf /python-build && \
rm -rf /var/lib/apt/lists/*

USER ${SESSION_USER}
ENV __MOUNTDIR__=${MOUNTDIR}
RUN curl -sSL https://install.python-poetry.org | python3 - --version=${POETRY_VERSION} && \
/home/${SESSION_USER}/.local/bin/poetry config virtualenvs.path ${VENVS_PATH}
WORKDIR ${WORKDIR}

0 comments on commit d1466a2

Please sign in to comment.