Skip to content
Snippets Groups Projects
Commit b529d20d authored by Gilquin's avatar Gilquin
Browse files

init: populate repository

parents
No related branches found
No related tags found
No related merge requests found
FROM mambaorg/micromamba:1.5.8 AS micromamba
FROM rocker/tidyverse:latest
# copy files from micromamba image
ARG MAMBA_USER=${DEFAULT_USER}
ARG MAMBA_USER_ID=1000
ARG MAMBA_USER_GID=1000
ENV MAMBA_USER=${MAMBA_USER}
ENV MAMBA_ROOT_PREFIX="/opt/conda"
ENV MAMBA_EXE="/bin/micromamba"
COPY --from=micromamba "${MAMBA_EXE}" "${MAMBA_EXE}"
COPY --from=micromamba /usr/local/bin/_activate_current_env.sh \
/usr/local/bin/_dockerfile_initialize_user_accounts.sh \
/usr/local/bin/_dockerfile_setup_root_prefix.sh \
/usr/local/bin/_dockerfile_shell.sh \
/usr/local/bin/
# setup mamba user
RUN /usr/local/bin/_dockerfile_initialize_user_accounts.sh && \
/usr/local/bin/_dockerfile_setup_root_prefix.sh
# install micromamba env
SHELL ["/usr/local/bin/_dockerfile_shell.sh"]
ENV MAMBA_ENV_DIR="/opt/conda/envs/py_basis"
COPY environment.yml /opt/environment.yml
COPY docker/scripts/micromamba_clean_env.sh docker/scripts/py_setup.sh /opt/docker/bin/
RUN /bin/micromamba create -f /opt/environment.yml && \
/bin/micromamba clean -a -y && \
chown -R "${DEFAULT_USER}":"${DEFAULT_USER}" "${MAMBA_ENV_DIR}" && \
/opt/docker/bin/micromamba_clean_env.sh
# python setup
RUN /opt/docker/bin/py_setup.sh
# local files and folders
*.log
#!/usr/bin/bash
PROJECT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd | xargs dirname )
cd "$PROJECT_DIR" || exit
docker build -t "${USER}/can-py-basis:latest" -f "Dockerfile" . 2>&1 | tee "docker/build.log"
#!/usr/bin/bash
PROJECT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd | xargs dirname )
docker run \
--rm \
-v "${PROJECT_DIR}":"${PROJECT_DIR}" \
-w "${PROJECT_DIR}" \
--name can-py-basis-quarto \
${USER}/can-py-basis:latest \
bash -c "quarto render ."
#!/usr/bin/bash
PROJECT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd | xargs dirname )
docker run \
--rm \
-it \
-v "${PROJECT_DIR}":"${PROJECT_DIR}" \
-w "${PROJECT_DIR}" \
-e USERID="$(id -u)" \
-e GROUPID="$(id -g)" \
-p 8787:8787 \
--name can-py-basis-rstudio \
${USER}/can-py-basis:latest
#!/usr/bin/bash -eu
PY_VERSION="python"
PY_VERSION+="$( "${MAMBA_ENV_DIR}/bin/python" --version | grep -Eo "3\.[0-9]*" )"
find ${MAMBA_ENV_DIR} -name '*.a' -delete && \
rm -rf ${MAMBA_ENV_DIR}/include && \
find ${MAMBA_ENV_DIR} -name '__pycache__' -type d -exec rm -rf '{}' '+' && \
rm -rf ${MAMBA_ENV_DIR}/lib/${PY_VERSION}/site-packages/pip ${MAMBA_ENV_DIR}/lib/${PY_VERSION}/idlelib ${MAMBA_ENV_DIR}/lib/${PY_VERSION}/ensurepip \
${MAMBA_ENV_DIR}/bin/x86_64-conda-linux-gnu-ld \
${MAMBA_ENV_DIR}/bin/sqlite3 \
${MAMBA_ENV_DIR}/bin/openssl \
${MAMBA_ENV_DIR}/share/terminfo && \
find ${MAMBA_ENV_DIR}/lib/${PY_VERSION}/site-packages/numpy -name 'tests' -type d -exec rm -rf '{}' '+' && \
find ${MAMBA_ENV_DIR}/lib/${PY_VERSION}/site-packages/pandas -name 'tests' -type d -exec rm -rf '{}' '+' && \
find ${MAMBA_ENV_DIR}/lib/${PY_VERSION}/site-packages/matplotlib -name 'tests' -type d -exec rm -rf '{}' '+' && \
find ${MAMBA_ENV_DIR}/lib/${PY_VERSION}/site-packages/matplotlib -name '__pycache__' -type d -exec rm -rf '{}' '+' && \
find ${MAMBA_ENV_DIR}/lib/${PY_VERSION}/site-packages -name '*.pyx' -delete && \
rm -rf ${MAMBA_ENV_DIR}/lib/${PY_VERSION}/site-packages/uvloop/loop.c
#!/usr/bin/bash -eu
# install reticulate
apt-get update -qq && \
install2.r --error --skipinstalled --ncpus -1 reticulate && \
rm -rf /tmp/downloaded_packages && \
strip /usr/local/lib/R/site-library/*/libs/*.so
# setup python path at RStudio launch time
cat <<EOF >"/home/${DEFAULT_USER}/.config/rstudio/rstudio-prefs.json"
{
"save_workspace": "never",
"always_save_history": false,
"reuse_sessions_for_project_links": true,
"posix_terminal_shell": "bash",
"python_project_environment_automatic_activate": true,
"python_path": "${MAMBA_ENV_DIR}/bin/python"
}
EOF
# setup reticulate environment variable
cat <<EOF >"/home/${DEFAULT_USER}/.Rprofile"
Sys.setenv("RETICULATE_PYTHON_ENV"="${MAMBA_ENV_DIR}")
Sys.setenv("RETICULATE_CONDA"="${MAMBA_EXE}")
EOF
chown "${DEFAULT_USER}:${DEFAULT_USER}" "/home/${DEFAULT_USER}/.Rprofile"
# change matplotlib default figure dpi
"${MAMBA_ENV_DIR}/bin/python" -c "import matplotlib; print(matplotlib.matplotlib_fname())" | \
xargs sed -i 's/^#figure.dpi:.*/figure.dpi: 300/'
name: py_basis
channels:
- bokeh
- conda-forge
dependencies:
- python=3.11.9
- numpy=2.0.1
- pandas=2.2.2
- matplotlib=3.9.1
- seaborn=0.13.2
- plotly=5.23.0
- bokeh=3.5.1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment