Last active
June 6, 2023 21:08
-
-
Save emattiza/3fbebd17ebcf1fbcf1419d2a20d0053d to your computer and use it in GitHub Desktop.
simple gdal docker python build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM python:3.10.10-slim as base | |
| ENV PYTHONFAULTHANDLER=1 \ | |
| PYTHONHASHSEED=random \ | |
| PYTHONUNBUFFERED=1 | |
| COPY ./install-packages /usr/local/bin/install-packages | |
| RUN install-packages build-essential libproj-dev gdal-bin libgdal-dev | |
| FROM base as builder | |
| RUN python -m venv .venv | |
| ENV PIP_DEFAULT_TIMEOUT=100 \ | |
| PIP_DISABLE_PIP_VERSION_CHECK=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| VIRTUAL_ENV=/app/.venv \ | |
| PATH="/app/.venv/bin:${PATH}" \ | |
| POETRY_VERSION=1.3.1 | |
| WORKDIR /app | |
| RUN python -m pip install setuptools==58 | |
| RUN python -m pip install gdal==`gdal-config --version` | |
| RUN python -m pip install --upgrade setuptools | |
| RUN python -m pip install poetry=="${POETRY_VERSION}" | |
| COPY pyproject.toml poetry.toml poetry.lock /app/ | |
| RUN mkdir -p /app/gdal_test && touch /app/gdal_test/__init__.py | |
| RUN poetry install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -eu | |
| _mode="$( | |
| _self="${0##*/}" | |
| case "$_self" in | |
| 'install-packages' | 'upgrade-packages') | |
| : "${_self%%-*}" | |
| ;; | |
| *) | |
| : | |
| ;; | |
| esac | |
| printf '%s\n' "$_" # Return value | |
| )" | |
| test "$_mode" == ':' && printf '%s\n' 'Invalid mode' && exit 1 | |
| if test "$_mode" == 'install' && [ $# = 0 ]; then | |
| echo >&2 "No packages specified" | |
| exit 1 | |
| fi | |
| # Block users from running this unless they're root. | |
| if [[ $EUID != 0 ]]; then | |
| echo >&2 "Run this script again as root to $_mode packages." | |
| exit 1 | |
| fi | |
| # Set a runlevel to avoid invoke-rc.d warnings | |
| # http://manpages.ubuntu.com/manpages/focal/man8/runlevel.8.html#environment | |
| # shellcheck disable=SC2034 | |
| RUNLEVEL=1 | |
| DAZZLE_MARKS="/var/lib/apt/dazzle-marks/" | |
| TIMESTAMP=$(date +%s) | |
| if [ ! -d "${DAZZLE_MARKS}" ]; then | |
| mkdir -p "${DAZZLE_MARKS}" | |
| fi | |
| debconf-set-selections <<<'debconf debconf/frontend select Noninteractive' | |
| apt-get update | |
| apt-get "$_mode" -yq --no-install-recommends "$@" | |
| debconf-set-selections <<<'debconf debconf/frontend select Readline' | |
| cp /var/lib/dpkg/status "${DAZZLE_MARKS}/${TIMESTAMP}.status" | |
| apt-get clean -y | |
| rm -rf \ | |
| /var/cache/debconf/* \ | |
| /var/lib/apt/lists/* \ | |
| /tmp/* \ | |
| /var/tmp/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This file is automatically @generated by Poetry and should not be changed by hand. | |
| package = [] | |
| [metadata] | |
| lock-version = "2.0" | |
| python-versions = "^3.10" | |
| content-hash = "53f2eabc9c26446fbcc00d348c47878e118afc2054778c3c803a0a8028af27d9" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [virtualenvs] | |
| in-project = true | |
| create = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [tool.poetry] | |
| name = "gdal-test" | |
| version = "0.1.0" | |
| description = "" | |
| authors = ["emattiza"] | |
| packages = [{include = "gdal_test"}] | |
| [tool.poetry.dependencies] | |
| python = "^3.10" | |
| [build-system] | |
| requires = ["poetry-core"] | |
| build-backend = "poetry.core.masonry.api" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment