diff --git a/Dockerfile b/Dockerfile index 354b358..e22b8af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,22 @@ -FROM ubuntu:20.04 - -MAINTAINER Fernando Aguilar "aguilarf@ifca.unican.es" +FROM python:3.11-slim AS base RUN apt-get update -y && \ apt-get install -y curl python3-pip python3-dev git vim lsof -RUN git clone https://github.com/ifca-advanced-computing/FAIR_eva.git - +COPY . /FAIR_eva WORKDIR /FAIR_eva - +RUN chmod +x scripts/entrypoint.sh +RUN pip3 install git+https://github.com/IFCA-Advanced-Computing/fair-eva-plugin-oai-pmh RUN pip3 install -r requirements.txt +RUN pip3 install . + +ARG FAIR_EVA_HOST=0.0.0.0 +ARG FAIR_EVA_PORT=9090 +ARG START_CMD="fair-eva" + +ENV FAIR_EVA_HOST=${FAIR_EVA_HOST} \ + FAIR_EVA_PORT=${FAIR_EVA_PORT} \ + START_CMD=${START_CMD} -EXPOSE 5000 9090 -RUN ls -RUN mv /FAIR_eva/config.ini.template /FAIR_eva/config.ini -RUN cd /FAIR_eva -RUN chmod 777 start.sh -RUN cat start.sh -CMD /FAIR_eva/start.sh +EXPOSE ${FAIR_EVA_PORT} +ENTRYPOINT ["/FAIR_eva/scripts/entrypoint.sh"] diff --git a/fair_eva/__init__.py b/fair_eva/__init__.py index 8931c99..aad19ac 100755 --- a/fair_eva/__init__.py +++ b/fair_eva/__init__.py @@ -9,6 +9,14 @@ def set_parser(): parser = argparse.ArgumentParser(description="FAIR EVA API server") + parser.add_argument( + "--host", + type=str, + metavar="HOST", + dest="host", + default="127.0.0.1", + help="Host IP where API server will run (default: 127.0.0.1)", + ) parser.add_argument( "-p", "--port", @@ -31,4 +39,4 @@ def main(): arguments={"title": "FAIR evaluator"}, resolver=RestyResolver("fair_eva.api"), ) - app.run(port=options_cli.port) + app.run(host=options_cli.host, port=options_cli.port) diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100644 index 0000000..7fbfe49 --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Entrypoint script for FAIR_eva Docker container +# This script handles environment variables and launches the fair-eva application + +# Set default values for environment variables +FAIR_EVA_HOST=${FAIR_EVA_HOST:-0.0.0.0} +FAIR_EVA_PORT=${FAIR_EVA_PORT:-9090} +START_CMD=${START_CMD:-fair-eva} + +# Build the command to run fair-eva +CMD="$START_CMD --host $FAIR_EVA_HOST --port $FAIR_EVA_PORT" + +# Execute the command +echo "Starting FAIR_eva with command: $CMD" +exec $CMD