forked from esm-tools/pycmor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.test
More file actions
67 lines (54 loc) · 2.26 KB
/
Dockerfile.test
File metadata and controls
67 lines (54 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Dockerfile for pycmor testing environment
# Uses micromamba for compatible HDF5/NetCDF/netcdf4-python stack
ARG PYTHON_VERSION=3.11
FROM mambaorg/micromamba:1.5.10
USER root
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
git-lfs \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Set working directory and give ownership to MAMBA_USER
WORKDIR /workspace
RUN chown -R $MAMBA_USER:$MAMBA_USER /workspace && \
chmod -R 755 /workspace
# Switch to micromamba user for conda operations
USER $MAMBA_USER
# Install Python and scientific stack via micromamba (ensures compatibility)
# This installs matching HDF5/NetCDF/netcdf4-python versions
ARG PYTHON_VERSION
RUN micromamba install -y -n base -c conda-forge \
python=${PYTHON_VERSION} \
hdf5 \
netcdf4 \
h5netcdf \
h5py \
pip \
&& micromamba clean --all --yes
# Activate the base environment for subsequent commands
ARG MAMBA_DOCKERFILE_ACTIVATE=1
# Copy project files
COPY --chown=$MAMBA_USER:$MAMBA_USER pyproject.toml versioneer.py ./
COPY --chown=$MAMBA_USER:$MAMBA_USER src/pycmor/_version.py src/pycmor/_version.py
COPY --chown=$MAMBA_USER:$MAMBA_USER . .
# Install pycmor and dev dependencies via pip (uses conda's Python/libs)
RUN pip install --no-cache-dir ".[dev,fesom,cmip7]"
# Pre-generate CMIP7 variable metadata for doctests (v1.2.2.2)
# Uses -a (all opportunities) and -m (variables metadata output)
# The -m file contains "Compound Name" structure used by load_metadata()
RUN mkdir -p /home/$MAMBA_USER/.cache/pycmor/cmip7_metadata && \
export_dreq_lists_json -a v1.2.2.2 \
/tmp/experiments.json \
-m /home/$MAMBA_USER/.cache/pycmor/cmip7_metadata/v1.2.2.2.json && \
rm /tmp/experiments.json
# Set environment variables for testing
ENV PREFECT_SERVER_EPHEMERAL_STARTUP_TIMEOUT_SECONDS=300
ENV PYTHONUNBUFFERED=1
ENV HDF5_USE_FILE_LOCKING=FALSE
ENV PYCMOR_CMIP7_METADATA_DIR=/home/mambauser/.cache/pycmor/cmip7_metadata
# Verify installation
RUN python -c "import h5py; print('h5py version:', h5py.__version__); print('HDF5 version:', h5py.version.hdf5_version)" && \
python -c "import netCDF4; print('netCDF4 version:', netCDF4.__version__)"
# Default command runs tests
CMD ["pytest", "-vvv", "--cov=src/pycmor", "tests/"]