|
| 1 | +# |
| 2 | +# Dockerfile for pandas development |
| 3 | +# |
| 4 | +# Usage: |
| 5 | +# ------- |
| 6 | +# |
| 7 | +# To make a local build of the container, from the 'Docker-dev' directory: |
| 8 | +# docker build --rm -f "Dockerfile" -t <build-tag> "." |
| 9 | +# |
| 10 | +# To use the container use the following command. It assumes that you are in |
| 11 | +# the root folder of the pandas git repository, making it available as |
| 12 | +# /home/pandas in the container. Whatever changes you make to that directory |
| 13 | +# are visible in the host and container. |
| 14 | +# The docker image is retrieved from the pandas dockerhub repository |
| 15 | +# |
| 16 | +# docker run --rm -it -v $(pwd):/home/pandas pandas/pandas-dev:<image-tag> |
| 17 | +# |
| 18 | +# By default the container will activate the conda environment pandas-dev |
| 19 | +# which contains all the dependencies needed for pandas development |
| 20 | +# |
| 21 | +# To build and install pandas run: |
| 22 | +# python setup.py build_ext -j 4 |
| 23 | +# python -m pip install -e . --no-build-isolation |
| 24 | +# |
| 25 | +# This image is based on: Ubuntu 20.04 (focal) |
| 26 | +# https://hub.docker.com/_/ubuntu/?tab=tags&name=focal |
| 27 | +# OS/ARCH: linux/amd64 |
| 28 | +FROM gitpod/workspace-base:latest |
| 29 | + |
| 30 | +ARG MAMBAFORGE_VERSION="22.9.0-1" |
| 31 | +ARG CONDA_ENV=pandas-dev |
| 32 | +ARG PANDAS_HOME="/home/pandas" |
| 33 | + |
| 34 | + |
| 35 | +# ---- Configure environment ---- |
| 36 | +ENV CONDA_DIR=/home/gitpod/mambaforge3 \ |
| 37 | + SHELL=/bin/bash |
| 38 | +ENV PATH=${CONDA_DIR}/bin:$PATH \ |
| 39 | + WORKSPACE=/workspace/pandas |
| 40 | + |
| 41 | +# ----------------------------------------------------------------------------- |
| 42 | +# ---- Creating as root - note: make sure to change to gitpod in the end ---- |
| 43 | +USER root |
| 44 | + |
| 45 | +# Avoid warnings by switching to noninteractive |
| 46 | +ENV DEBIAN_FRONTEND=noninteractive |
| 47 | + |
| 48 | +# Configure apt and install packages |
| 49 | +RUN apt-get update \ |
| 50 | + && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ |
| 51 | + # |
| 52 | + # Install tzdata and configure timezone (fix for tests which try to read from "/etc/localtime") |
| 53 | + && apt-get -y install tzdata \ |
| 54 | + && ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime \ |
| 55 | + && dpkg-reconfigure -f noninteractive tzdata \ |
| 56 | + # |
| 57 | + # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed |
| 58 | + && apt-get -y install git iproute2 procps iproute2 lsb-release \ |
| 59 | + # |
| 60 | + # cleanup |
| 61 | + && apt-get autoremove -y \ |
| 62 | + && apt-get clean -y \ |
| 63 | + && rm -rf /var/lib/apt/lists/* |
| 64 | + |
| 65 | +# Switch back to dialog for any ad-hoc use of apt-get |
| 66 | +ENV DEBIAN_FRONTEND=dialog |
| 67 | + |
| 68 | +# Allows this Dockerfile to activate conda environments |
| 69 | +SHELL ["/bin/bash", "--login", "-o", "pipefail", "-c"] |
| 70 | + |
| 71 | +# ----------------------------------------------------------------------------- |
| 72 | +# ---- Installing mamba ---- |
| 73 | +RUN wget -q -O mambaforge3.sh \ |
| 74 | + "https://github.com/conda-forge/miniforge/releases/download/$MAMBAFORGE_VERSION/Mambaforge-$MAMBAFORGE_VERSION-Linux-x86_64.sh" && \ |
| 75 | + bash mambaforge3.sh -p ${CONDA_DIR} -b && \ |
| 76 | + rm mambaforge3.sh |
| 77 | + |
| 78 | +# ----------------------------------------------------------------------------- |
| 79 | +# ---- Copy needed files ---- |
| 80 | +# basic workspace configurations |
| 81 | +COPY ./gitpod/workspace_config /usr/local/bin/workspace_config |
| 82 | + |
| 83 | +RUN chmod a+rx /usr/local/bin/workspace_config && \ |
| 84 | + workspace_config |
| 85 | + |
| 86 | +# the container to create a conda environment from it |
| 87 | +COPY environment.yml /tmp/environment.yml |
| 88 | + |
| 89 | +RUN mamba env create -f /tmp/environment.yml |
| 90 | +# ---- Create conda environment ---- |
| 91 | +RUN conda activate $CONDA_ENV && \ |
| 92 | + mamba install ccache -y && \ |
| 93 | + # needed for docs rendering later on |
| 94 | + python -m pip install --no-cache-dir sphinx-autobuild && \ |
| 95 | + conda clean --all -f -y && \ |
| 96 | + rm -rf /tmp/* |
| 97 | + |
| 98 | +# ----------------------------------------------------------------------------- |
| 99 | +# Always make sure we are not root |
| 100 | +USER gitpod |
0 commit comments