diff --git a/.dockerignore b/.dockerignore index 5157228..6bc898f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,26 @@ +.github/ .venv/ +.vscode/ .idea/ ci/ -.env +doc/ +gurobi/ +htmlcov/ +local_test/ *.egg-info/ -temp/ +unit_test/ +.env +.env.local +.env-template +.gitignore +.taplo.toml +CHANGELOG.md +CONTRIBUTING.md +dev.Dockerfile +docker-compose.worker-only.yml +docker-compose.yml +LICENSE +run.bat +run.sh +run_windows.sh +test-results.xml diff --git a/.gitignore b/.gitignore index 12eba45..5f197c2 100644 --- a/.gitignore +++ b/.gitignore @@ -223,4 +223,6 @@ test-results.xml .env.* -temp/ \ No newline at end of file +temp/ +gurobi/ +.idea/ diff --git a/Dockerfile b/Dockerfile index c2ee81d..183da13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,26 @@ -FROM python:3.8-slim-buster +FROM python:3.8-slim-bookworm WORKDIR /app +RUN apt update && \ + apt install -y wget && \ + apt-get clean + +ENV GUROBI_HOME=/app/gurobi/ +ENV PATH="/app/gurobi/bin:$PATH" +ENV LD_LIBRARY_PATH="/app/gurobi/lib" +ENV CASADI_GUROBI_VERSION="110" +ENV GUROBI_VERSION_URL="11.0.3" +ENV GUROBI_VERSION_URL_MAJOR="11.0" + +# This env var is for casadi. +ENV GUROBI_VERSION="$CASADI_GUROBI_VERSION" + +# This env var is for gurobi +ENV GRB_LICENSE_FILE="/app/gurobi/gurobi.lic" + + +RUN mkdir -p /app/gurobi && \ + wget -qO- https://packages.gurobi.com/${GUROBI_VERSION_URL_MAJOR}/gurobi${GUROBI_VERSION_URL}_linux64.tar.gz | tar xvz --strip-components=2 -C /app/gurobi COPY requirements.txt /app/grow_worker/requirements.txt RUN pip install -r /app/grow_worker/requirements.txt --no-cache-dir diff --git a/docker-compose.worker-only.yml b/docker-compose.worker-only.yml new file mode 100644 index 0000000..c5c144f --- /dev/null +++ b/docker-compose.worker-only.yml @@ -0,0 +1,33 @@ +networks: + omotes: + external: true + +services: + grow_worker: + build: + context: . + environment: + INFLUXDB_HOSTNAME: omotes_influxdb + INFLUXDB_PORT: 8096 + INFLUXDB_USERNAME: root + INFLUXDB_PASSWORD: 9012 + + RABBITMQ_HOSTNAME: rabbitmq-nwn + RABBITMQ_PORT: 5672 + RABBITMQ_USERNAME: root + RABBITMQ_PASSWORD: 5678 + RABBITMQ_VIRTUALHOST: omotes_celery + + GROW_TASK_TYPE: grow_optimizer_default + LOG_LEVEL: DEBUG + volumes: + - "./gurobi.lic:/app/gurobi/gurobi.lic" + networks: + - omotes + deploy: + replicas: 3 + resources: + limits: + cpus: '4' + memory: 4gb + memswap_limit: 4gb diff --git a/run.sh b/run.sh index e754c64..af73a6b 100755 --- a/run.sh +++ b/run.sh @@ -3,4 +3,16 @@ . .venv/bin/activate . ci/linux/_load_dot_env.sh .env.local +export DIR_TO_ROOT="$PWD" + +export GUROBI_HOME="${DIR_TO_ROOT}/gurobi" +export PATH="${GUROBI_HOME}/bin:$PATH" +export LD_LIBRARY_PATH="${GUROBI_HOME}/lib" +export CASADI_GUROBI_VERSION="110" +export GUROBI_VERSION_URL="11.0.3" +export GUROBI_VERSION_URL_MAJOR="11.0" + +export GUROBI_VERSION="$CASADI_GUROBI_VERSION" +export GRB_LICENSE_FILE="${DIR_TO_ROOT}/gurobi.lic" + PYTHONPATH="src/" python3 -m grow_worker.worker