-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1627 from henrykironde/dokr2
Setup Docker registry uploader
- Loading branch information
Showing
2 changed files
with
149 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
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 | ||
|
||
|
This file contains 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