From 2eada731b7ed2f63ec3627d164fbc261b0182858 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Tue, 3 Oct 2023 17:18:30 +0545 Subject: [PATCH] Added support for docker CPU --- backend/Dockerfile_CPU | 32 ++++++++++++++++++ docker-compose-cpu.yml | 76 ++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 7 +--- 3 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 backend/Dockerfile_CPU create mode 100644 docker-compose-cpu.yml diff --git a/backend/Dockerfile_CPU b/backend/Dockerfile_CPU new file mode 100644 index 00000000..5fa52037 --- /dev/null +++ b/backend/Dockerfile_CPU @@ -0,0 +1,32 @@ +FROM tensorflow/tensorflow:2.9.2 + +RUN apt-get update && apt-get install -y python3-opencv +RUN add-apt-repository ppa:ubuntugis/ppa && apt-get update +RUN apt-get update +RUN apt-get install -y gdal-bin +RUN apt-get install -y libgdal-dev +ENV CPLUS_INCLUDE_PATH=/usr/include/gdal +ENV C_INCLUDE_PATH=/usr/include/gdal + +#install numpy before gdal +RUN pip install numpy==1.23.5 + +# pip install dependencies. +RUN pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version` + +COPY docker/ramp/docker-requirements.txt docker-requirements.txt +RUN pip install -r docker-requirements.txt + +# pip install solaris -- try with tmp-free build +COPY docker/ramp/solaris /tmp/solaris +RUN pip install /tmp/solaris --use-feature=in-tree-build + +RUN pip install scikit-fmm --use-feature=in-tree-build + +RUN pip install setuptools --upgrade + +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt + +WORKDIR /app +COPY . /app \ No newline at end of file diff --git a/docker-compose-cpu.yml b/docker-compose-cpu.yml new file mode 100644 index 00000000..f54319b0 --- /dev/null +++ b/docker-compose-cpu.yml @@ -0,0 +1,76 @@ +version: "3.8" + +services: + postgres: + restart: always + image: postgis/postgis + container_name: pgsql + environment: + - POSTGRES_DB=ai + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=admin + volumes: + - ./postgres-data:/var/lib/postgresql/data + ports: + - "5434:5432" + + redis: + image: redis + container_name: redis + ports: + - "6379:6379" + + backend-api: + build: + context: ./backend + dockerfile: Dockerfile + container_name: api + command: python manage.py runserver 0.0.0.0:8000 + + ports: + - 8000:8000 + volumes: + - ./backend:/app + - ${RAMP_HOME}:/RAMP_HOME + - ${TRAINING_WORKSPACE}:/TRAINING_WORKSPACE + depends_on: + - redis + - postgres + + backend-worker: + build: + context: ./backend + dockerfile: Dockerfile + container_name: worker + command: celery -A aiproject worker --loglevel=INFO --concurrency=1 + + volumes: + - ./backend:/app + - ${RAMP_HOME}:/RAMP_HOME + - ${TRAINING_WORKSPACE}:/TRAINING_WORKSPACE + depends_on: + - backend-api + - redis + - postgres + + worker-dashboard: + image: mher/flower + container_name: flower + command: celery --broker=redis://redis:6379// flower --address=0.0.0.0 --port=5000 + ports: + - 5500:5000 + depends_on: + - backend-api + - redis + - backend-worker + + frontend: + build: + context: ./frontend + dockerfile: Dockerfile.frontend + container_name: frontend + command: npm start -- --host 0.0.0.0 --port 3000 + ports: + - 3000:3000 + depends_on: + - backend-api diff --git a/docker-compose.yml b/docker-compose.yml index 7d949280..ac37dbee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,12 +26,7 @@ services: dockerfile: Dockerfile container_name: api command: python manage.py runserver 0.0.0.0:8000 - deploy: - resources: - reservations: - devices: - - driver: nvidia - capabilities: [gpu] + ports: - 8000:8000 volumes: