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

migrate /etc/noteable to /var/run/noteable with symlink #57

Merged
merged 16 commits into from
Oct 20, 2023
Merged
5 changes: 5 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ includes:
rust: ./Taskfile.rust.yaml
deno: ./Taskfile.deno.yaml

vars:
NBL_HOME_DIR: /var/run/noteable

tasks:
copy-root-files:
desc: Copy files from the root of the repository to the base build directories
Expand All @@ -32,11 +35,13 @@ tasks:
- >-
docker buildx build {{.LANGUAGE}}/{{.IDENTIFIER}}/{{.NBL_LANGUAGE_VERSION}} {{.CLI_ARGS}} \
--build-arg "NBL_LANGUAGE_VERSION={{.NBL_LANGUAGE_VERSION}}" \
--build-arg "NBL_HOME_DIR={{.NBL_HOME_DIR}}" \
--target "{{.BUILD_TARGET}}" \
--tag "local/kernel-{{.LANGUAGE}}-{{.NBL_LANGUAGE_VERSION}}-{{.IDENTIFIER}}{{.TAG_SUFFIX}}:{{.TAG}}"
requires:
vars: [LANGUAGE, IDENTIFIER, NBL_LANGUAGE_VERSION]
vars:
BUILD_TARGET: '{{default "base" .BUILD_TARGET}}'
NBL_HOME_DIR: '{{default "/var/run/noteable" .NBL_HOME_DIR}}'
TAG_SUFFIX: '{{default "" .TAG_SUFFIX}}'
TAG: '{{default "dev" .TAG}}'
36 changes: 20 additions & 16 deletions deno/base/1.37/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,29 @@
# ---
# Deno is installed from a PR that adds Jupyter support
# Rust 1.72 is required
ARG NBL_DENO_VERSION="1.37-dev"
shouples marked this conversation as resolved.
Show resolved Hide resolved
FROM rust:1.72 as base

ARG NBL_HOME_DIR=/var/run/noteable

# User/group setup
USER root

ENV NB_USER="noteable" \
NB_UID=4004 \
NB_GID=4004
NB_UID=4004 \
NB_GID=4004

RUN groupadd --gid 4004 noteable && \
useradd --uid 4004 \
--shell /bin/false \
--create-home \
--no-log-init \
--gid noteable noteable \
--home-dir /srv/noteable && \
chown --recursive noteable:noteable /srv/noteable && \
mkdir -p /etc/noteable && chown noteable:noteable /etc/noteable
useradd --uid 4004 \
--shell /bin/false \
--create-home \
--no-log-init \
--gid noteable noteable \
--home-dir "${NBL_HOME_DIR}" && \
chown --recursive noteable:noteable "${NBL_HOME_DIR}"

# TEMPORARY: symlink the previous /etc/noteable to the new NBL_HOME_DIR (/var/run/noteable) dir
# until all other services are migrated and the old /etc/noteable can be removed
RUN ln -s "${NBL_HOME_DIR}" /etc/noteable

WORKDIR /tmp

Expand All @@ -36,14 +40,14 @@ USER noteable

# use the deno installer and upgrade to the specified (canary) build
# https://docs.deno.com/runtime/manual/references/contributing/release_schedule
ENV DENO_INSTALL=/srv/noteable
ENV DENO_INSTALL=${NBL_HOME_DIR}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -fsSL https://deno.land/x/install/install.sh | sh
# deno installs to `DENO_INSTALL/bin`, so we'll add to PATH for follow-on deno commands
ENV PATH="${DENO_INSTALL}/bin/:${PATH}"
RUN deno upgrade \
--canary \
--version=48e695a2c89edad6e4880e7decfdb36d524f8279
--canary \
--version=48e695a2c89edad6e4880e7decfdb36d524f8279

# the kernel needs the deno kernelspec discoverable locally before it can start
# hadolint ignore=DL3059
Expand All @@ -52,9 +56,9 @@ RUN deno --unstable jupyter --install
COPY secrets_helper.sh /tmp/secrets_helper.sh
COPY run.sh /usr/local/bin

ENV HOME="/srv/noteable"
ENV HOME="${NBL_HOME_DIR}"

WORKDIR /etc/noteable/project
WORKDIR ${NBL_HOME_DIR}/project
EXPOSE 50001-50005

ENTRYPOINT ["tini", "-g", "--"]
Expand Down
9 changes: 5 additions & 4 deletions python/base-gpu/3.10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# hadolint ignore=DL3006
FROM base AS main

ARG NBL_HOME_DIR=/var/run/noteable
ARG NBL_PYTHON_VERSION=3.10

USER root
Expand Down Expand Up @@ -52,9 +53,9 @@ RUN /usr/bin/apt-install Aptfile
COPY gpu.Aptfile .
RUN /usr/bin/apt-install gpu.Aptfile

ENV PATH="/srv/noteable/.local/bin:${PATH}" \
HOME="/srv/noteable" \
XDG_CACHE_HOME="/srv/noteable/.cache/" \
ENV PATH="${NBL_HOME_DIR}/.local/bin:${PATH}" \
HOME="${NBL_HOME_DIR}" \
XDG_CACHE_HOME="${NBL_HOME_DIR}/.cache/" \
GOOGLE_APPLICATION_CREDENTIALS="/vault/secrets/gcp-credentials"

RUN chown -R noteable:noteable "${CONDA_DIR}"
Expand All @@ -80,4 +81,4 @@ ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_DIR/lib/:$CUDNN_PATH/lib \
# Overwrite the base run.sh to include `mamba` usage
COPY run.sh /usr/local/bin

WORKDIR /etc/noteable/project
WORKDIR ${NBL_HOME_DIR}/project
9 changes: 5 additions & 4 deletions python/base-gpu/3.11/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# hadolint ignore=DL3006
FROM base AS main

ARG NBL_HOME_DIR=/var/run/noteable
ARG NBL_PYTHON_VERSION=3.11

USER root
Expand Down Expand Up @@ -52,9 +53,9 @@ RUN /usr/bin/apt-install Aptfile
COPY gpu.Aptfile .
RUN /usr/bin/apt-install gpu.Aptfile

ENV PATH="/srv/noteable/.local/bin:${PATH}" \
HOME="/srv/noteable" \
XDG_CACHE_HOME="/srv/noteable/.cache/" \
ENV PATH="${NBL_HOME_DIR}/.local/bin:${PATH}" \
HOME="${NBL_HOME_DIR}" \
XDG_CACHE_HOME="${NBL_HOME_DIR}/.cache/" \
GOOGLE_APPLICATION_CREDENTIALS="/vault/secrets/gcp-credentials"

RUN chown -R noteable:noteable "${CONDA_DIR}"
Expand All @@ -80,4 +81,4 @@ ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_DIR/lib/:$CUDNN_PATH/lib \
# Overwrite the base run.sh to include `mamba` usage
COPY run.sh /usr/local/bin

WORKDIR /etc/noteable/project
WORKDIR ${NBL_HOME_DIR}/project
9 changes: 5 additions & 4 deletions python/base-gpu/3.9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
FROM base AS main

ARG NBL_PYTHON_VERSION=3.9
ARG NBL_HOME_DIR=/var/run/noteable

USER root

Expand Down Expand Up @@ -52,9 +53,9 @@ RUN /usr/bin/apt-install Aptfile
COPY gpu.Aptfile .
RUN /usr/bin/apt-install gpu.Aptfile

ENV PATH="/srv/noteable/.local/bin:${PATH}" \
HOME="/srv/noteable" \
XDG_CACHE_HOME="/srv/noteable/.cache/" \
ENV PATH="${NBL_HOME_DIR}/.local/bin:${PATH}" \
HOME="${NBL_HOME_DIR}" \
XDG_CACHE_HOME="${NBL_HOME_DIR}/.cache/" \
GOOGLE_APPLICATION_CREDENTIALS="/vault/secrets/gcp-credentials"

RUN chown -R noteable:noteable "${CONDA_DIR}"
Expand All @@ -80,4 +81,4 @@ ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_DIR/lib/:$CUDNN_PATH/lib \
# Overwrite the base run.sh to include `mamba` usage
COPY run.sh /usr/local/bin

WORKDIR /etc/noteable/project
WORKDIR ${NBL_HOME_DIR}/project
21 changes: 13 additions & 8 deletions python/base/3.10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ARG NBL_PYTHON_VERSION=3.10
FROM python:${NBL_PYTHON_VERSION}-slim-bullseye as base

# User/group setup
ARG NBL_HOME_DIR=/var/run/noteable

USER root

ENV NB_USER="noteable" \
Expand All @@ -20,11 +22,14 @@ RUN groupadd --gid 4004 noteable && \
--create-home \
--no-log-init \
--gid noteable noteable \
--home-dir /srv/noteable && \
chown --recursive noteable:noteable /srv/noteable && \
--home-dir "${NBL_HOME_DIR}" && \
chown --recursive noteable:noteable "${NBL_HOME_DIR}" && \
mkdir /opt/venv && chown noteable:noteable /opt/venv && \
mkdir /etc/ipython && chown noteable:noteable /etc/ipython && \
mkdir -p /etc/noteable && chown noteable:noteable /etc/noteable
mkdir /etc/ipython && chown noteable:noteable /etc/ipython

# TEMPORARY: symlink the previous /etc/noteable to the new NBL_HOME_DIR (/var/run/noteable) dir
# until all other services are migrated and the old /etc/noteable can be removed
RUN ln -s "${NBL_HOME_DIR}" /etc/noteable

WORKDIR /tmp

Expand All @@ -49,12 +54,12 @@ RUN pip install --no-cache-dir -r /tmp/base_requirements.txt
COPY secrets_helper.sh /tmp/secrets_helper.sh
COPY run.sh /usr/local/bin

ENV HOME="/srv/noteable" \
PYTHONPATH="/srv/noteable/.local/lib/python${NBL_PYTHON_VERSION}/site-packages:${PYTHONPATH}" \
XDG_CACHE_HOME="/srv/noteable/.cache/" \
ENV HOME="${NBL_HOME_DIR}" \
PYTHONPATH="${NBL_HOME_DIR}/.local/lib/python${NBL_PYTHON_VERSION}/site-packages:${PYTHONPATH}" \
XDG_CACHE_HOME="${NBL_HOME_DIR}/.cache/" \
GOOGLE_APPLICATION_CREDENTIALS="/vault/secrets/gcp-credentials"

WORKDIR /etc/noteable/project
WORKDIR ${NBL_HOME_DIR}/project
EXPOSE 50001-50005

ENTRYPOINT ["/tini", "-g", "--"]
Expand Down
22 changes: 14 additions & 8 deletions python/base/3.11/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
ARG NBL_PYTHON_VERSION=3.11
FROM python:${NBL_PYTHON_VERSION}-slim-bullseye as base

ARG NBL_HOME_DIR=/var/run/noteable
ARG NBL_PYTHON_VERSION
tizz98 marked this conversation as resolved.
Show resolved Hide resolved

# User/group setup
USER root

Expand All @@ -20,11 +23,14 @@ RUN groupadd --gid 4004 noteable && \
--create-home \
--no-log-init \
--gid noteable noteable \
--home-dir /srv/noteable && \
chown --recursive noteable:noteable /srv/noteable && \
--home-dir "${NBL_HOME_DIR}" && \
chown --recursive noteable:noteable "${NBL_HOME_DIR}" && \
mkdir /opt/venv && chown noteable:noteable /opt/venv && \
mkdir /etc/ipython && chown noteable:noteable /etc/ipython && \
mkdir -p /etc/noteable && chown noteable:noteable /etc/noteable
mkdir /etc/ipython && chown noteable:noteable /etc/ipython

# TEMPORARY: symlink the previous /etc/noteable to the new NBL_HOME_DIR (/var/run/noteable) dir
# until all other services are migrated and the old /etc/noteable can be removed
RUN ln -s "${NBL_HOME_DIR}" /etc/noteable

WORKDIR /tmp

Expand All @@ -49,12 +55,12 @@ RUN pip install --no-cache-dir -r /tmp/base_requirements.txt
COPY secrets_helper.sh /tmp/secrets_helper.sh
COPY run.sh /usr/local/bin

ENV HOME="/srv/noteable" \
PYTHONPATH="/srv/noteable/.local/lib/python${NBL_PYTHON_VERSION}/site-packages:${PYTHONPATH}" \
XDG_CACHE_HOME="/srv/noteable/.cache/" \
ENV HOME="${NBL_HOME_DIR}" \
PYTHONPATH="${NBL_HOME_DIR}/.local/lib/python${NBL_PYTHON_VERSION}/site-packages:${PYTHONPATH}" \
XDG_CACHE_HOME="${NBL_HOME_DIR}/.cache/" \
GOOGLE_APPLICATION_CREDENTIALS="/vault/secrets/gcp-credentials"

WORKDIR /etc/noteable/project
WORKDIR ${NBL_HOME_DIR}/project
EXPOSE 50001-50005

ENTRYPOINT ["/tini", "-g", "--"]
Expand Down
22 changes: 14 additions & 8 deletions python/base/3.9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
ARG NBL_PYTHON_VERSION=3.9
FROM python:${NBL_PYTHON_VERSION}-slim-bullseye as base

ARG NBL_HOME_DIR=/var/run/noteable
ARG NBL_PYTHON_VERSION
tizz98 marked this conversation as resolved.
Show resolved Hide resolved

# User/group setup
USER root

Expand All @@ -20,11 +23,14 @@ RUN groupadd --gid 4004 noteable && \
--create-home \
--no-log-init \
--gid noteable noteable \
--home-dir /srv/noteable && \
chown --recursive noteable:noteable /srv/noteable && \
--home-dir "${NBL_HOME_DIR}" && \
chown --recursive noteable:noteable "${NBL_HOME_DIR}" && \
mkdir /opt/venv && chown noteable:noteable /opt/venv && \
mkdir /etc/ipython && chown noteable:noteable /etc/ipython && \
mkdir -p /etc/noteable && chown noteable:noteable /etc/noteable
mkdir /etc/ipython && chown noteable:noteable /etc/ipython

# TEMPORARY: symlink the previous /etc/noteable to the new ""${NBL_HOME_DIR}"" dir
# until all other services are migrated and the old /etc/noteable can be removed
RUN ln -s "${NBL_HOME_DIR}" /etc/noteable

WORKDIR /tmp

Expand All @@ -49,12 +55,12 @@ RUN pip install --no-cache-dir -r /tmp/base_requirements.txt
COPY secrets_helper.sh /tmp/secrets_helper.sh
COPY run.sh /usr/local/bin

ENV HOME="/srv/noteable" \
PYTHONPATH="/srv/noteable/.local/lib/python${NBL_PYTHON_VERSION}/site-packages:${PYTHONPATH}" \
XDG_CACHE_HOME="/srv/noteable/.cache/" \
ENV HOME="${NBL_HOME_DIR}" \
PYTHONPATH="${NBL_HOME_DIR}/.local/lib/python${NBL_PYTHON_VERSION}/site-packages:${PYTHONPATH}" \
XDG_CACHE_HOME="${NBL_HOME_DIR}/.cache/" \
GOOGLE_APPLICATION_CREDENTIALS="/vault/secrets/gcp-credentials"

WORKDIR /etc/noteable/project
WORKDIR ${NBL_HOME_DIR}/project
EXPOSE 50001-50005

ENTRYPOINT ["/tini", "-g", "--"]
Expand Down
2 changes: 1 addition & 1 deletion python/noteable/3.10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN pip install --no-cache-dir -r /tmp/noteable_requirements.txt
# hadolint ignore=SC1008,DL3059
RUN python -c "import dx, noteable, psutil, sidecar_comms"

COPY .pythonrc /srv/noteable/.
COPY .pythonrc /var/run/noteable/.
COPY ipython_config.py /etc/ipython
COPY git_credential_helper.py /git_credential_helper.py
COPY git-wrapper.sh /usr/local/bin/git
Expand Down
2 changes: 1 addition & 1 deletion python/noteable/3.9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN pip install --no-cache-dir -r /tmp/noteable_requirements.txt
# hadolint ignore=DL3059
RUN python -c "import dx, noteable, psutil, sidecar_comms"

COPY .pythonrc /srv/noteable/.
COPY .pythonrc /var/run/noteable/.
COPY ipython_config.py /etc/ipython
COPY git_credential_helper.py /git_credential_helper.py
COPY git-wrapper.sh /usr/local/bin/git
Expand Down
2 changes: 1 addition & 1 deletion python/noteable/ipython_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

c.SqlMagic.feedback = False
c.SqlMagic.autopandas = True
c.NTBLMagic.project_dir = "/etc/noteable/project"
c.NTBLMagic.project_dir = "/var/run/noteable/project"
c.NoteableDataLoaderMagic.return_head = False
c.IPythonKernel._execute_sleep = 0.15
# 10 minutes to support large files
Expand Down
17 changes: 11 additions & 6 deletions r/base/4.3.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
ARG NBL_R_VERSION=4.3.0
FROM r-base:${NBL_R_VERSION} as base

ARG NBL_HOME_DIR=/var/run/noteable

# User/group setup
USER root

Expand All @@ -20,11 +22,14 @@ RUN groupadd --gid 4004 noteable && \
--create-home \
--no-log-init \
--gid noteable noteable \
--home-dir /srv/noteable && \
chown --recursive noteable:noteable /srv/noteable && \
mkdir -p /etc/noteable && chown noteable:noteable /etc/noteable && \
--home-dir "${NBL_HOME_DIR}" && \
chown --recursive noteable:noteable "${NBL_HOME_DIR}" && \
chown --recursive noteable:noteable /usr/local/lib/R/site-library

# TEMPORARY: symlink the previous /etc/noteable to the new NBL_HOME_DIR (/var/run/noteable) dir
# until all other services are migrated and the old /etc/noteable can be removed
RUN ln -s "${NBL_HOME_DIR}" /etc/noteable

# Install tini to manage passing signals to the child kernel process
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
Expand All @@ -44,11 +49,11 @@ RUN R -e "install.packages('IRkernel', repos='http://cran.us.r-project.org')"
COPY secrets_helper.sh /tmp/secrets_helper.sh
COPY run.sh /usr/local/bin

ENV HOME="/srv/noteable" \
XDG_CACHE_HOME="/srv/noteable/.cache/" \
ENV HOME="${NBL_HOME_DIR}" \
XDG_CACHE_HOME="${NBL_HOME_DIR}/.cache/" \
GOOGLE_APPLICATION_CREDENTIALS="/vault/secrets/gcp-credentials"

WORKDIR /etc/noteable/project
WORKDIR ${NBL_HOME_DIR}/project
EXPOSE 50001-50005

ENTRYPOINT ["/tini", "-g", "--"]
Expand Down
4 changes: 3 additions & 1 deletion r/noteable/4.3.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# hadolint ignore=DL3006
FROM base as main

ARG NBL_HOME_DIR=/var/run/noteable

USER root

# install python for reticulate support
Expand All @@ -18,4 +20,4 @@ COPY requirements.R /tmp/requirements.R
RUN R -e "source('/tmp/requirements.R')"

# similarly, copy any R commands that need to run on startup
COPY .Rprofile /srv/noteable/.Rprofile
COPY .Rprofile ${NBL_HOME_DIR}/.Rprofile
Loading