Skip to content

Instantly share code, notes, and snippets.

@zacdezgeo
Created October 7, 2021 16:29
Show Gist options
  • Save zacdezgeo/da623b89da723efd6c11a76bcfc08320 to your computer and use it in GitHub Desktop.
Save zacdezgeo/da623b89da723efd6c11a76bcfc08320 to your computer and use it in GitHub Desktop.
FROM osgeo/gdal:ubuntu-full-3.2.2 AS builder-image
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt-get install --no-install-recommends -y \
python3.9 python3.9-dev python3.9-venv python3-pip python3-wheel build-essential && \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN python3.9 -m venv /home/myuser/venv
ENV PATH="/home/myuser/venv/bin:$PATH"
COPY requirements.txt .
RUN pip3 install --no-cache-dir wheel
RUN pip3 install --no-cache-dir -r requirements.txt
WORKDIR /home/myuser/app
COPY src src
COPY setup.py .
RUN python setup.py develop
FROM osgeo/gdal:ubuntu-full-3.2.2 AS runner-image
RUN apt update && apt-get install --no-install-recommends -y \
python3.9 python3.9-dev python3.9-venv python3-pip python3-wheel build-essential && \
apt-get clean && rm -rf /var/lib/apt/lists/*
ENV PYTHONUNBUFFERED=1
ENV VIRTUAL_ENV=/home/myuser/venv
ENV PATH="/home/myuser/venv/bin:$PATH"
RUN useradd --create-home myuser
COPY --from=builder-image /home/myuser/venv /home/myuser/venv
COPY --from=builder-image /home/myuser/app /home/myuser/app
RUN chmod +x $VIRTUAL_ENV/bin/activate
USER myuser
WORKDIR /home/myuser/app
COPY tests tests/
COPY settings.toml .
CMD $VIRTUAL_ENV/bin/activate && pytest -p no:cacheprovider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment