diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e45791cb..4d3bfaa5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -85,6 +85,6 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: deployment/docker/centos/Dockerfile + file: deployment/docker/rockylinux/Dockerfile push: true tags: ${{ join(fromJson(steps.gettags.outputs.tags)) }} diff --git a/deployment/docker/rockylinux/.dockerignore b/deployment/docker/rockylinux/.dockerignore new file mode 100644 index 00000000..e2bec014 --- /dev/null +++ b/deployment/docker/rockylinux/.dockerignore @@ -0,0 +1,3 @@ +Dockerfile +.git +.gitignore diff --git a/deployment/docker/rockylinux/Dockerfile b/deployment/docker/rockylinux/Dockerfile new file mode 100644 index 00000000..ef577694 --- /dev/null +++ b/deployment/docker/rockylinux/Dockerfile @@ -0,0 +1,23 @@ +#docker build . -t searchengine +# docker build . -f deployment/docker/rockylinux/Dockerfile -t searchengine +FROM rockylinux/rockylinux:9.0 +USER root +RUN dnf update -y +RUN dnf groupinstall "Development Tools" -y +RUN dnf install libpq-devel -y +RUN dnf install python3-pip -y +RUN dnf install -y python3-devel.x86_64 +RUN dnf clean all && rm -rf /var/cache/yum +RUN mkdir /searchengine +ADD deployment/docker/rockylinux/start_gunicorn_serch_engine.sh /searchengine +ADD deployment/docker/rockylinux/run_app.sh /searchengine +ADD . /searchengine +RUN cd /searchengine +RUN mkdir /etc/searchengine +RUN mkdir /etc/searchengine/chachedata +RUN mkdir /etc/searchengine/logs +WORKDIR /searchengine +RUN pip3 install -r requirements.txt +RUN pip3 install gunicorn +EXPOSE 5577 +ENTRYPOINT ["bash", "run_app.sh"] diff --git a/deployment/docker/rockylinux/run_app.sh b/deployment/docker/rockylinux/run_app.sh new file mode 100644 index 00000000..a1cac35a --- /dev/null +++ b/deployment/docker/rockylinux/run_app.sh @@ -0,0 +1,18 @@ +#!/bin/bash +echo "$@" + +#test if the configuration file exists, if not it will copy it from the app configuration folder +test -f /etc/searchengine/.app_config.yml || cp /searchengine/configurations/app_config.yml /etc/searchengine/.app_config.yml + +#Check the script input +if [[ $@ == run_app* ]] ; then + url_perfix=${@/run_app/} + echo using prefix: $url_perfix + bash start_gunicorn_serch_engine.sh $url_perfix +elif [ -z "$@" ] || [ "$@" = "run_app" ]; then + echo "Starting the app" + bash start_gunicorn_serch_engine.sh +else + echo "$@" + python3 manage.py "$@" +fi diff --git a/deployment/docker/rockylinux/start_gunicorn_serch_engine.sh b/deployment/docker/rockylinux/start_gunicorn_serch_engine.sh new file mode 100644 index 00000000..9b8fd400 --- /dev/null +++ b/deployment/docker/rockylinux/start_gunicorn_serch_engine.sh @@ -0,0 +1,26 @@ +#!/bin/sh +NAME="omero_search_engine" +USER root +APPPATH=/searchengine +SOCKFILE=/etc/searchengine/sock3 #change this to project_dir/sock (new file will be created) +echo "Starting $NAME as `whoami`" +export PATH="$APPPATH:$PATH" +echo "staring the app" +# Create the run directory if it doesn't exist +RUNDIR=$(dirname $SOCKFILE) +echo "$RUNDIR" +test -d $RUNDIR || mkdir -p $RUNDIR +LOGS=/etc/searchengine/logs +LOGSDIR=$(dirname $LOGS) +test -d $LOGSDIR || mkdir -p $LOGSDIR +user=$USER +echo "Start Gunicorn ...." +echo "$HOME" +echo pwd +cd $APPPATH +if [ -z "$@" ]; then + exec gunicorn "omero_search_engine:create_app('production')" -b 0.0.0.0:5577 --timeout 0 --name "$NAME" --bind=unix:$SOCKFILE --log-file=$LOGSDIR/logs/engine_gunilog.log --access-logfile=$LOGSDIR/logs/engine_access.log -error-logfile=$LOGSDIR/logs/engine_logs/engine_error.log --workers 4 +else + echo Run with SCRIPT_NAME=$@ + SCRIPT_NAME=/"$@"/ exec gunicorn "omero_search_engine:create_app('production')" -b 0.0.0.0:5577 --timeout 0 --name "$NAME" --bind=unix:$SOCKFILE --log-file=$LOGSDIR/logs/engine_gunilog.log --access-logfile=$LOGSDIR/logs/engine_access.log -error-logfile=$LOGSDIR/logs/engine_logs/engine_error.log --workers 4 +fi