fix restoring database #225
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: Build | |
on: | |
push: | |
tags: | |
branches: | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:11 | |
env: | |
POSTGRES_USER: postgress | |
POSTGRES_PASSWORD: passwprd | |
POSTGRES_DB: omero | |
ports: | |
- 5432/tcp | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
elasticsearch: | |
image: elasticsearch:8.8.1 | |
ports: | |
- 9200/tcp | |
env: | |
es_api_basic_auth_username: "elastic" | |
ELASTIC_PASSWORD: "elasticsearch_user_password" | |
options: -e="discovery.type=single-node" --health-cmd="curl -k -u elastic:elasticsearch_user_password https://localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=10 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
#test the app before bulding the image | |
- name: Install dependencies and test | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt; | |
# Configure database url | |
python manage.py set_database_configuration -u localhost -s ${{ job.services.postgres.ports[5432] }} -n postgress -p passwprd | |
# configure elasticsearch | |
python manage.py set_elasticsearch_configuration -e localhost:${{ job.services.elasticsearch.ports[9200] }} | |
# download and extract the database backup file | |
wget https://downloads.openmicroscopy.org/images/omero_db_searchengine.zip -P app_data | |
unzip app_data/omero_db_searchengine.zip -d app_data/ | |
# run restore omero database | |
python manage.py restore_postgresql_database | |
# run indexing indexing | |
python manage.py get_index_data_from_database -b False | |
# run tests | |
python -m unittest discover -s unit_tests | |
upload: | |
needs: build | |
if: startsWith(github.ref, 'refs/tags') | |
runs-on: ubuntu-latest | |
env: | |
name: openmicroscopy/omero-searchengine | |
steps: | |
- name: Get prefix | |
id: getprefix | |
run: | | |
if [ ! -z ${{ env.name }} ]; then | |
echo "prefix=${{ env.name }}:" >> $GITHUB_OUTPUT | |
else | |
echo "prefix=${{ github.repository }}:" >> $GITHUB_OUTPUT | |
fi | |
- name: Get other tags | |
id: gettags | |
uses: jupyterhub/[email protected] | |
with: | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
prefix: "${{ steps.getprefix.outputs.prefix }}" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- uses: actions/checkout@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: display docker account | |
run: echo ${{ secrets.DOCKER_LOGIN }} | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: deployment/docker/rockylinux/Dockerfile | |
push: true | |
tags: ${{ join(fromJson(steps.gettags.outputs.tags)) }} |