Skip to content

Commit

Permalink
Merge pull request #1627 from henrykironde/dokr2
Browse files Browse the repository at this point in the history
Setup Docker registry uploader
  • Loading branch information
henrykironde committed Oct 28, 2021
2 parents df077bc + 2c1caa1 commit f9f435b
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 16 deletions.
140 changes: 140 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ main ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: docker.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]

services:
mysqldb_retriever:
image: mysql:5.7
env:
MYSQL_USER: travis
MYSQL_PASSWORD: Password12!
MYSQL_ROOT_PASSWORD: Password12!
MYSQL_DATABASE: testdb_retriever
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- uses: actions/checkout@v2

- name: Set up Postgresql with Postgis
uses: huaxk/postgis-action@v1
with:
postgresql version: '11'
postgresql user: 'postgres'
postgresql password: 'Password12!'
postgresql db: 'testdb_retriever'

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
env:
LC_ALL : en_US.UTF-8
ENV LANG : en_US.UTF-8
ENV LANGUAGE : en_US.UTF-8
TZ: America/New_York
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update && sudo apt-get install -y --no-install-recommends apt-utils
sudo apt-get install -y --force-yes tzdata
sudo apt-get install -y --force-yes build-essential wget git locales locales-all > /dev/null
sudo apt-get install -y --force-yes libpq-dev
sudo apt-get install libgdal-dev
sudo apt-get install gdal-bin
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
pip install GDAL==3.2.3
sudo apt-get install -y --force-yes postgis
- name: Setup paths and files
run : |
cd ..
chmod 0755 retriever/cli_tools/entrypoint.sh
sh retriever/cli_tools/entrypoint.sh
echo "export PATH="/usr/bin/python:$PATH"" >> ~/.profile
echo "export PYTHONPATH="/usr/bin/python:$PYTHONPATH"" >> ~/.profile
echo "export PGPASSFILE="~/.pgpass"" >> ~/.profile
chmod 0644 ~/.profile
- name: PostGIS check version
run : |
export PGPASSWORD='Password12!'
psql -d testdb_retriever -U postgres -h localhost -p 5432 -c "SELECT PostGIS_version();"
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest yapf codecov pytest-cov pytest-xdist -U
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install retriever
run: |
pip install -e .
export PGPASSFILE="~/.pgpass"
chmod 600 ~/.pgpass
chmod 600 ~/.my.cnf
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tag-custom: latest

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: docker/Dockerfile


25 changes: 9 additions & 16 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
# Download base image ubuntu 18.04
FROM ubuntu:18.04
# Download base image ubuntu .04
FROM osgeo/gdal

MAINTAINER Weecology "https://github.com/weecology/retriever"

# Installing Gdal and configuring it
RUN add-apt-repository ppa:ubuntugis/ppa &&\
RUN export CPLUS_INCLUDE_PATH=/usr/include/gdal &&\
export C_INCLUDE_PATH=/usr/include/gdal &&\
apt-get update && apt-get install -y --no-install-recommends apt-utils &&\
# Manually install tzdata to allow for non-interactive install
apt-get install -y --force-yes tzdata &&\
apt-get install -y --force-yes build-essential wget git locales locales-all > /dev/null &&\
apt-get install -y --force-yes postgresql-client mariadb-client > /dev/null &&\
apt-get install -y --force-yes libpq-dev &&\
apt-get install gdal-bin &&\
apt-get install libgdal-dev &&\
export CPLUS_INCLUDE_PATH=/usr/include/gdal &&\
export C_INCLUDE_PATH=/usr/include/gdal &&\
pip install GDAL

# Installing GDAL
RUN apt-add-repository ppa:ubuntugis/ubuntugis-unstable &&\
apt install -y gdal-bin python-gdal python3-gdal
apt-get install -y --force-yes libgdal-dev &&\
apt install -y --force-yes gdal-bin &&\
# Installing postgis
apt-get install -y --force-yes postgis

# Set encoding
ENV LC_ALL en_US.UTF-8
Expand Down Expand Up @@ -51,10 +47,7 @@ RUN pip install pymysql &&\
pip install Pillow &&\
pip install kaggle &&\
pip install inquirer

# Install Postgis after Python is setup
RUN apt-get install -y --force-yes postgis

RUN pip install GDAL
COPY . ./retriever
RUN chmod 0755 /retriever/cli_tools/entrypoint.sh
ENTRYPOINT ["/retriever/cli_tools/entrypoint.sh"]
Expand Down

0 comments on commit f9f435b

Please sign in to comment.