-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
105 lines (86 loc) · 3.64 KB
/
Dockerfile
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# =============================================================================
# Test environment.
#
# Example:
# > docker build -t curryer_test . --target test
# > docker run -a stdout -a stderr --rm \
# -e SPACETRACK_USER=$SPACETRACK_USER -e SPACETRACK_PSWD=$SPACETRACK_PSWD \
# curryer_test
# -----------------------------------------------------------------------------
# Python version with which to test (must be supported and available on dockerhub)
ARG BASE_IMAGE_PYTHON_VERSION
FROM python:${BASE_IMAGE_PYTHON_VERSION:-3.11}-slim AS test
USER root
ENV BASE_DIR /app/curryer
ENV DATA_DIR $BASE_DIR/data
WORKDIR $BASE_DIR
# Create virtual environment and permanently activate it for this image
# This adds not only the venv python executable but also all installed entrypoints to the PATH
# Upgrade pip to the latest version because poetry uses pip in the background to install packages
ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip install --upgrade pip
# Update the OS tools and install dependencies.
RUN apt-get update
RUN apt-get install -y curl
# Install poetry and add to path.
RUN curl -sSL https://install.python-poetry.org | python -
ENV PATH="$PATH:/root/.local/bin"
# Copy data files.
RUN mkdir -p $DATA_DIR/generic \
&& curl https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de430.bsp \
--output $DATA_DIR/generic/de430.bsp
COPY data $DATA_DIR
# Copy library files.
# TODO: First copy depdencies and install python before the whole lib? Makes things faster locally.
COPY bin $BASE_DIR/bin
COPY curryer $BASE_DIR/curryer
COPY tests $BASE_DIR/tests
COPY README.md $BASE_DIR
COPY pyproject.toml $BASE_DIR
# Ensure pip is upgraded
RUN pip install --upgrade pip
# Install all dependencies (including dev deps) specified in pyproject.toml
RUN poetry install
# Download third-party data.
ENV CURRYER_DATA_DIR=$DATA_DIR
RUN PROJ_DOWNLOAD_DIR=$(python -c "import pyproj; print(pyproj.datadir.get_user_data_dir())") \
&& mkdir -p ${PROJ_DOWNLOAD_DIR} \
&& curl https://cdn.proj.org/us_nga_egm96_15.tif --output ${PROJ_DOWNLOAD_DIR}/us_nga_egm96_15.tif
ENTRYPOINT pytest \
-v \
--junitxml=junit.xml \
--disable-warnings \
tests
# =============================================================================
# Debug environment.
#
# Example:
# > docker build -t curryer_debug . --target debug
# > docker run --security-opt seccomp=unconfined --privileged -it --rm curryer_debug
#
# > docker run -v .:/workspace -p 8889:8889 --security-opt seccomp=unconfined --privileged -it --rm curryer_debug
# > cd /workspace ; export JUPYTER_CONFIG_DIR=/workspace/notebooks
# > jupyter lab . --allow-root --ip 0.0.0.0 --port 8889 --no-browser
# -----------------------------------------------------------------------------
FROM test AS debug
# Command line tools and debug dependencies.
RUN apt-get install -y man less vim which tree
RUN pip install matplotlib jupyterlab cartopy basemap basemap-data-hires
CMD []
ENTRYPOINT ["/bin/bash"]
# =============================================================================
# L1A Geolocation Integration Test Case
#
# Example:
# > docker build -t curryer_clarreo_l1a . --target demo
# > docker run -a stdout -a stderr --rm curryer_clarreo_l1a
# or to override with a different input file:
# > docker run -a stdout -a stderr --rm -v `pwd`:/app/curryer/tests/data/demo curryer_clarreo_l1a
# -----------------------------------------------------------------------------
FROM test AS demo
SHELL ["/usr/bin/bash"]
WORKDIR $BASE_DIR
CMD ["tests/sit4_l1a_geolocation.py", "--demo", "--output_dir", "tests/data/demo"]
ENTRYPOINT ["python3"]