Skip to content

Commit

Permalink
Update dockerfile and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
robbibt committed Aug 1, 2024
1 parent c0ece89 commit 2b5f60e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 73 deletions.
52 changes: 26 additions & 26 deletions .github/workflows/dea-coastlines-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,31 @@ jobs:
echo "PGPORT=5432" >> $GITHUB_ENV
echo "PGHOST=localhost" >> $GITHUB_ENV
# - name: Build DEA Coastlines docker image
# timeout-minutes: 30
# shell: bash
# run: |
# docker build -t dea_coastlines .
- name: Build DEA Coastlines docker image
timeout-minutes: 30
shell: bash
run: |
docker build -t dea_coastlines .
# - name: Run integration tests
# run: |
# # Download tide modelling files and unzip
# # TODO: Replace with S3 sync from dea-non-public-data
# wget --no-verbose https://www.dropbox.com/s/uemd8ib2vfw5nad/tide_models.zip?dl=1 -O tide_models.zip
# unzip -q tide_models.zip
- name: Run integration tests
run: |
# Download tide modelling files and unzip
# TODO: Replace with S3 sync from dea-non-public-data
wget --no-verbose https://www.dropbox.com/s/uemd8ib2vfw5nad/tide_models.zip?dl=1 -O tide_models.zip
unzip -q tide_models.zip
# # Run integration tests using Docker, setting up datacube access, AWS configuration and
# # adding volumes that provide access to tide model data and allow us to export artifacts
# # from the run
# docker run \
# --net=host \
# --env DATACUBE_DB_URL \
# --env AWS_SESSION_TOKEN \
# --env AWS_REGION \
# --env AWS_ACCESS_KEY_ID \
# --env AWS_SECRET_ACCESS_KEY \
# --env AWS_SESSION_TOKEN \
# --volume ${GITHUB_WORKSPACE}:/code \
# --volume ${GITHUB_WORKSPACE}/tide_models:/var/share/tide_models \
# --volume ${GITHUB_WORKSPACE}/artifacts:/mnt/artifacts \
# dea_coastlines pytest -v --cov=coastlines --cov-report=xml tests
# Run integration tests using Docker, setting up datacube access, AWS configuration and
# adding volumes that provide access to tide model data and allow us to export artifacts
# from the run
docker run \
--net=host \
--env DATACUBE_DB_URL \
--env AWS_SESSION_TOKEN \
--env AWS_REGION \
--env AWS_ACCESS_KEY_ID \
--env AWS_SECRET_ACCESS_KEY \
--env AWS_SESSION_TOKEN \
--volume ${GITHUB_WORKSPACE}:/code \
--volume ${GITHUB_WORKSPACE}/tide_models:/var/share/tide_models \
--volume ${GITHUB_WORKSPACE}/artifacts:/mnt/artifacts \
dea_coastlines pytest -v --cov=coastlines --cov-report=xml tests
85 changes: 38 additions & 47 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,57 +1,48 @@
FROM osgeo/gdal:ubuntu-small-3.4.1 as base

ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

RUN apt-get update \
&& apt-get install -y \
# Build tools
build-essential \
git \
python3-pip \
# For Psycopg2
libpq-dev python3-dev \
# For SSL
ca-certificates \
# for pg_isready
postgresql-client \
# Try adding libgeos-dev
libgeos-dev \
# Tidy up
# Base image with:
# - Ubuntu 22.04
# - Python 3.10.12
# - GDAL 3.7.3, released 2023/10/30
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.7.3

ENV DEBIAN_FRONTEND=noninteractive \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8

# Apt installation
RUN apt-get update && \
apt-get install -y \
build-essential \
fish \
git \
vim \
htop \
wget \
unzip \
python3-pip \
libpq-dev \
&& apt-get autoclean && \
apt-get autoremove && \
rm -rf /var/lib/{apt,dpkg,cache,log}

# Install pip-tools
RUN pip install pip-tools

# Environment can be whatever is supported by setup.py
# so, either deployment, test
ARG ENVIRONMENT=deployment
# ARG ENVIRONMENT=test
# Pip installation
RUN mkdir -p /conf
COPY requirements.txt /conf/
RUN pip install -r /conf/requirements.txt \
&& pip install --no-cache-dir awscli

RUN echo "Environment is: $ENVIRONMENT"
# Copy source code and install it
RUN mkdir -p /code
WORKDIR /code
ADD . /code

COPY requirements.txt /tmp/
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r /tmp/requirements.txt \
--no-binary rasterio \
--no-binary shapely \
--no-binary fiona \
# Extras
&& pip install --no-cache-dir awscli requests
RUN echo "Installing dea-coastlines through the Dockerfile."
RUN pip install --extra-index-url="https://packages.dea.ga.gov.au" .

# Set up a nice workdir and add the live code
ENV APPDIR=/code
RUN mkdir -p $APPDIR
WORKDIR $APPDIR
ADD . $APPDIR
RUN pip freeze && pip check

RUN if [ "$ENVIRONMENT" = "deployment" ] ; then\
pip install .[$ENVIRONMENT] ; \
else \
pip install --editable .[$ENVIRONMENT] ; \
fi


CMD ["python", "--version"]

RUN deacoastlines-raster --help \
# Make sure it's working
RUN deacoastlines-raster --help \
&& deacoastlines-vector --help

0 comments on commit 2b5f60e

Please sign in to comment.