Merge pull request #6 from praekeltfoundation/build-v-8 #27
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
name: Docker image build | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
INDEXER_REPO: nyaruka/rp-indexer | |
GREP_TIMEOUT: 60 | |
PGPASSWORD: temba | |
strategy: | |
matrix: | |
INDEXER_VERSION: ["8.0.0"] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: docker/setup-buildx-action@v1 | |
- name: Run ElasticSearch | |
run: docker run --name elasticsearch -d -p 9200:9200 -e 'discovery.type=single-node' elasticsearch:7.10.1 | |
- name: Install PostgreSQL | |
uses: nyaruka/postgis-action@v2 | |
with: | |
postgresql version: "13" | |
postgis version: "3.1" | |
postgresql db: temba | |
postgresql user: temba | |
postgresql password: temba | |
- name: Build image | |
uses: docker/build-push-action@v2 | |
with: | |
push: false | |
load: true | |
context: . | |
tags: indexer | |
build-args: | | |
INDEXER_REPO=${{env.INDEXER_REPO}} | |
INDEXER_VERSION=${{matrix.INDEXER_VERSION}} | |
- name: Create postgresql tables | |
run: | | |
psql -h localhost -d temba -U temba -f ci/database.sql | |
- name: Test image | |
# First run there are errors while it creates the indexes, so we only check for errors on second run | |
run: | | |
docker run --name indexer --env-file docker.envfile --link postgis --link elasticsearch --detach indexer | |
timeout ${{env.GREP_TIMEOUT}} grep -m 1 'completed indexing' <(docker logs --follow indexer 2>&1) | |
docker stop indexer | |
docker rm indexer | |
docker run --name indexer --env-file docker.envfile --link postgis --link elasticsearch --detach indexer | |
timeout ${{env.GREP_TIMEOUT}} grep -m 1 'completed indexing' <(docker logs --follow indexer 2>&1) | |
grep -v 'error' <(docker logs indexer 2>&1) | |
- name: debug outputs | |
if: always() | |
run: | | |
docker ps | |
docker images | |
docker logs indexer | |
- name: Create image tags | |
uses: docker/metadata-action@v3 | |
id: tags | |
with: | |
images: | | |
praekeltfoundation/rp-indexer | |
ghcr.io/praekeltfoundation/rp-indexer-docker | |
tags: | | |
type=pep440,pattern=v{{major}},value=${{matrix.INDEXER_VERSION}} | |
type=pep440,pattern=v{{major}}.{{minor}},value=${{matrix.INDEXER_VERSION}} | |
type=pep440,pattern=v{{version}},value=${{matrix.INDEXER_VERSION}} | |
- name: login to ghcr | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{github.actor}} | |
password: ${{secrets.GITHUB_TOKEN}} | |
- name: login to docker hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{secrets.DOCKER_USERNAME}} | |
password: ${{secrets.DOCKER_PASSWORD}} | |
- name: Build and push image | |
uses: docker/build-push-action@v2 | |
with: | |
push: ${{github.event_name != 'pull_request'}} | |
tags: ${{steps.tags.outputs.tags}} | |
context: . | |
build-args: | | |
INDEXER_REPO=${{env.INDEXER_REPO}} | |
INDEXER_VERSION=${{matrix.INDEXER_VERSION}} |