From 52478817286bf77ae67265ba86ff6f0b9f91f0ef Mon Sep 17 00:00:00 2001 From: andrewthien Date: Thu, 4 Jul 2024 11:39:51 +0100 Subject: [PATCH 01/19] Add docker file for Next client --- .dockerignore | 1 + app/next-client-app/.dockerignore | 7 ++++ app/next-client-app/Dockerfile | 57 +++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 app/next-client-app/.dockerignore create mode 100644 app/next-client-app/Dockerfile diff --git a/.dockerignore b/.dockerignore index f6de88dc5..4c3724d67 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ react-client-app/node_modules +next-client-app/node_modules \ No newline at end of file diff --git a/app/next-client-app/.dockerignore b/app/next-client-app/.dockerignore new file mode 100644 index 000000000..72e9aa425 --- /dev/null +++ b/app/next-client-app/.dockerignore @@ -0,0 +1,7 @@ +Dockerfile +.dockerignore +node_modules +npm-debug.log +README.md +.next +.git \ No newline at end of file diff --git a/app/next-client-app/Dockerfile b/app/next-client-app/Dockerfile new file mode 100644 index 000000000..3d9874c60 --- /dev/null +++ b/app/next-client-app/Dockerfile @@ -0,0 +1,57 @@ +FROM node:18-alpine AS base + +# Install dependencies only when needed +FROM base AS deps +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +RUN apk add --no-cache libc6-compat +WORKDIR /app + +# Install dependencies based on the preferred package manager +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ +RUN \ + if [ -f package-lock.json ]; then npm ci; \ + else echo "Lockfile not found." && exit 1; \ + fi + + +# Rebuild the source code only when needed +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +# Build the app +RUN \ + if [ -f package-lock.json ]; then npm run build; \ + else echo "Lockfile not found." && exit 1; \ + fi + +# Production image, copy all the files and run next +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV production + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder /app/public ./public + +# Set the correct permission for prerender cache +RUN mkdir .next +RUN chown nextjs:nodejs .next + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +ENV PORT 3000 + +# server.js is created by next build from the standalone output +# https://nextjs.org/docs/pages/api-reference/next-config-js/output +CMD HOSTNAME="0.0.0.0" node server.js \ No newline at end of file From 432e776260ecb11d685547e316fab6c9c056e39d Mon Sep 17 00:00:00 2001 From: andrewthien Date: Thu, 4 Jul 2024 13:46:57 +0100 Subject: [PATCH 02/19] Add docker file for workers functions --- app/workers/.dockerignore | 1 + app/workers/.funcignore | 1 + app/workers/.gitignore | 48 +++++++++++++++++++++++++++++ app/workers/.vscode/extensions.json | 5 +++ app/workers/Dockerfile | 11 +++++++ app/workers/function_app.py | 6 ++++ app/workers/requirements.txt | 5 +++ 7 files changed, 77 insertions(+) create mode 100644 app/workers/.dockerignore create mode 100644 app/workers/.funcignore create mode 100644 app/workers/.gitignore create mode 100644 app/workers/.vscode/extensions.json create mode 100644 app/workers/Dockerfile create mode 100644 app/workers/function_app.py create mode 100644 app/workers/requirements.txt diff --git a/app/workers/.dockerignore b/app/workers/.dockerignore new file mode 100644 index 000000000..1927772bc --- /dev/null +++ b/app/workers/.dockerignore @@ -0,0 +1 @@ +local.settings.json \ No newline at end of file diff --git a/app/workers/.funcignore b/app/workers/.funcignore new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/app/workers/.funcignore @@ -0,0 +1 @@ + diff --git a/app/workers/.gitignore b/app/workers/.gitignore new file mode 100644 index 000000000..f15ac3fc6 --- /dev/null +++ b/app/workers/.gitignore @@ -0,0 +1,48 @@ +bin +obj +csx +.vs +edge +Publish + +*.user +*.suo +*.cscfg +*.Cache +project.lock.json + +/packages +/TestResults + +/tools/NuGet.exe +/App_Data +/secrets +/data +.secrets +appsettings.json +local.settings.json + +node_modules +dist + +# Local python packages +.python_packages/ + +# Python Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# Azurite artifacts +__blobstorage__ +__queuestorage__ +__azurite_db*__.json \ No newline at end of file diff --git a/app/workers/.vscode/extensions.json b/app/workers/.vscode/extensions.json new file mode 100644 index 000000000..dde673dcd --- /dev/null +++ b/app/workers/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "ms-azuretools.vscode-azurefunctions" + ] +} \ No newline at end of file diff --git a/app/workers/Dockerfile b/app/workers/Dockerfile new file mode 100644 index 000000000..179713af6 --- /dev/null +++ b/app/workers/Dockerfile @@ -0,0 +1,11 @@ +# To enable ssh & remote debugging on app service change the base image to the one below +# FROM mcr.microsoft.com/azure-functions/python:4-python3.11-appservice +FROM mcr.microsoft.com/azure-functions/python:4-python3.11 + +ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ + AzureFunctionsJobHost__Logging__Console__IsEnabled=true + +COPY requirements.txt / +RUN pip install -r /requirements.txt + +COPY . /home/site/wwwroot \ No newline at end of file diff --git a/app/workers/function_app.py b/app/workers/function_app.py new file mode 100644 index 000000000..e9b5526d2 --- /dev/null +++ b/app/workers/function_app.py @@ -0,0 +1,6 @@ +import azure.functions as func +import datetime +import json +import logging + +app = func.FunctionApp() \ No newline at end of file diff --git a/app/workers/requirements.txt b/app/workers/requirements.txt new file mode 100644 index 000000000..c403baf77 --- /dev/null +++ b/app/workers/requirements.txt @@ -0,0 +1,5 @@ +# Do not include azure-functions-worker in this file +# The Python Worker is managed by the Azure Functions platform +# Manually managing azure-functions-worker may cause unexpected issues + +azure-functions \ No newline at end of file From d9ca99741b7280d9ece8413f4be02e525de9b2c0 Mon Sep 17 00:00:00 2001 From: andrewthien Date: Thu, 4 Jul 2024 16:52:54 +0100 Subject: [PATCH 03/19] Update docker-compose, docker file and entrypooint --- app/entrypoint.sh | 13 +++++++++- app/workers/Dockerfile | 18 +++++++++++--- app/workers/requirements.txt | 5 ---- docker-compose.yml | 47 +++++++++++++++++++++++++++++++++++- 4 files changed, 73 insertions(+), 10 deletions(-) delete mode 100644 app/workers/requirements.txt diff --git a/app/entrypoint.sh b/app/entrypoint.sh index a7e05f280..32ba30bee 100644 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -7,8 +7,19 @@ npm run build # Wait until DB is available wait-for-it ${COCONNECT_DB_HOST}:${COCONNECT_DB_PORT} -- echo "Database is ready! Listening on ${COCONNECT_DB_HOST}:${COCONNECT_DB_PORT}" -# Collect static files for serving +# Inside api directory cd /api + +# Run Django migrations +python manage.py migrate + +# Load OMOP table and field names into the database +python manage.py loaddata mapping + +# Create superuser +python manage.py createsuperuser + +# Collect static files for serving rm -rf staticfiles mkdir staticfiles python /api/manage.py collectstatic diff --git a/app/workers/Dockerfile b/app/workers/Dockerfile index 179713af6..39e646c3a 100644 --- a/app/workers/Dockerfile +++ b/app/workers/Dockerfile @@ -3,9 +3,21 @@ FROM mcr.microsoft.com/azure-functions/python:4-python3.11 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ - AzureFunctionsJobHost__Logging__Console__IsEnabled=true + AzureFunctionsJobHost__Logging__Console__IsEnabled=true \ + AzureFunctionsWebHost__hostid=carrot-worker -COPY requirements.txt / -RUN pip install -r /requirements.txt +# Set a working directory +WORKDIR /app + +# Copy pyproject.toml and poetry.lock +COPY pyproject.toml poetry.lock ./ + +# Install Poetry +RUN pip install poetry + +# Export requirements from pyproject.toml and install them +RUN poetry config virtualenvs.create false \ + && poetry export --format requirements.txt --output /api/requirements.txt --without-hashes \ + && pip install --no-cache-dir -r /api/requirements.txt COPY . /home/site/wwwroot \ No newline at end of file diff --git a/app/workers/requirements.txt b/app/workers/requirements.txt deleted file mode 100644 index c403baf77..000000000 --- a/app/workers/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Do not include azure-functions-worker in this file -# The Python Worker is managed by the Azure Functions platform -# Manually managing azure-functions-worker may cause unexpected issues - -azure-functions \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 4a6b44138..f57300ef0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -name: carrot-mapper-dev +name: carrot-mapper-dev-test services: db: @@ -9,6 +9,15 @@ services: environment: POSTGRES_PASSWORD: postgres + omop-db: + image: postgres:latest + environment: + - POSTGRES_DB=omop + - POSTGRES_PASSWORD=password + # use port 5433 becaue port 5432 is used for the main db. Is this correct? + ports: + - 5433:5433 + azurite: image: mcr.microsoft.com/azure-storage/azurite restart: always @@ -17,6 +26,40 @@ services: - "10001:10001" - "10002:10002" + next-client: + image: carrot-next-client + build: + context: app/next-client-app + dockerfile: Dockerfile + ports: + - 3000:3000 + env_file: + - .env + # Mount the code directory + volumes: + - ./app/next-client-app:/app/next-client-app + + workers: + image: carrot-workers + build: + context: app/workers + dockerfile: Dockerfile + # This port was assumingly taken from https://learn.microsoft.com/en-us/azure/azure-functions/functions-deploy-container?tabs=acr%2Cbash%2Cazure-cli&pivots=programming-language-python + ports: + - 8080:80 + env_file: + - local.settings.json + # Mount the code directory + volumes: + - ./app/workers:/app/workers + + omop-lite: + image: ghcr.io/andyrae/omop-lite + volumes: + - ./vocabs:/vocabs + depends_on: + - omop-db + web: image: carrot build: @@ -31,3 +74,5 @@ services: depends_on: - db - azurite + - workers + - omop-lite From 457cd1d3cb0c6300f8f3555c3f61d882e2a0a0eb Mon Sep 17 00:00:00 2001 From: andrewthien Date: Tue, 9 Jul 2024 17:52:19 +0100 Subject: [PATCH 04/19] tesing ideas --- docker-compose.yml | 81 ++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index f57300ef0..2797ff5e8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,16 +7,7 @@ services: ports: - 5432:5432 environment: - POSTGRES_PASSWORD: postgres - - omop-db: - image: postgres:latest - environment: - - POSTGRES_DB=omop - - POSTGRES_PASSWORD=password - # use port 5433 becaue port 5432 is used for the main db. Is this correct? - ports: - - 5433:5433 + - POSTGRES_PASSWORD=postgres azurite: image: mcr.microsoft.com/azure-storage/azurite @@ -26,39 +17,45 @@ services: - "10001:10001" - "10002:10002" - next-client: - image: carrot-next-client - build: - context: app/next-client-app - dockerfile: Dockerfile - ports: - - 3000:3000 - env_file: - - .env - # Mount the code directory - volumes: - - ./app/next-client-app:/app/next-client-app + # next-client: + # image: carrot-next-client + # build: + # context: app/next-client-app + # dockerfile: Dockerfile + # ports: + # - 3000:3000 + # environment: + # - BACKEND_URL: http://web:8000 + # - BACKEND_ORIGIN: "web:8000" + # # Mount the code directory + # volumes: + # - ./app/next-client-app:/app/next-client-app - workers: - image: carrot-workers - build: - context: app/workers - dockerfile: Dockerfile - # This port was assumingly taken from https://learn.microsoft.com/en-us/azure/azure-functions/functions-deploy-container?tabs=acr%2Cbash%2Cazure-cli&pivots=programming-language-python - ports: - - 8080:80 - env_file: - - local.settings.json - # Mount the code directory - volumes: - - ./app/workers:/app/workers + # workers: + # image: carrot-workers + # build: + # context: app/workers + # dockerfile: Dockerfile + # # This port was assumingly taken from https://learn.microsoft.com/en-us/azure/azure-functions/functions-deploy-container?tabs=acr%2Cbash%2Cazure-cli&pivots=programming-language-python + # ports: + # - 8080:80 + # env_file: + # - local.settings.json + # # Mount the code directory + # volumes: + # - ./app/workers:/app/workers + # depends_on: + # - web - omop-lite: - image: ghcr.io/andyrae/omop-lite - volumes: - - ./vocabs:/vocabs - depends_on: - - omop-db + # omop-lite: + # image: ghcr.io/andyrae/omop-lite + # volumes: + # - ./vocabs:/vocabs + # depends_on: + # - db + # environment: + # - DB_PASSWORD: password + # - DB_NAME: omop web: image: carrot @@ -74,5 +71,3 @@ services: depends_on: - db - azurite - - workers - - omop-lite From a69be35a9aaa00646ddcd0d11461b777f022f7a6 Mon Sep 17 00:00:00 2001 From: andrewthien Date: Mon, 22 Jul 2024 11:49:06 +0100 Subject: [PATCH 05/19] modify and attempt to continue --- app/Dockerfile | 2 +- app/next-client-app/Dockerfile | 2 +- app/workers/Dockerfile | 8 ++++---- docker-compose.yml | 22 +++++++++++++++++----- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/Dockerfile b/app/Dockerfile index 5d8a3946d..83550f366 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -26,7 +26,7 @@ RUN addgroup -q django && \ # Copy 3 files to /react-client-app directory, which can be used for building dependencies RUN mkdir /react-client-app -COPY ./react-client-app/package.json ./react-client-app/package-lock.json ./react-client-app/snowpack.config.js /react-client-app +COPY ./react-client-app/package.json ./react-client-app/package-lock.json ./react-client-app/snowpack.config.js /react-client-app/ RUN chown -R django:django /react-client-app # Install nvm as django user, and install all dependencies diff --git a/app/next-client-app/Dockerfile b/app/next-client-app/Dockerfile index 3d9874c60..481e66f40 100644 --- a/app/next-client-app/Dockerfile +++ b/app/next-client-app/Dockerfile @@ -4,7 +4,7 @@ FROM node:18-alpine AS base FROM base AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat -WORKDIR /app +WORKDIR /app/next-client-app # Install dependencies based on the preferred package manager COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ diff --git a/app/workers/Dockerfile b/app/workers/Dockerfile index 39e646c3a..3439b924c 100644 --- a/app/workers/Dockerfile +++ b/app/workers/Dockerfile @@ -7,7 +7,7 @@ ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsWebHost__hostid=carrot-worker # Set a working directory -WORKDIR /app +WORKDIR /app/workers # Copy pyproject.toml and poetry.lock COPY pyproject.toml poetry.lock ./ @@ -16,8 +16,8 @@ COPY pyproject.toml poetry.lock ./ RUN pip install poetry # Export requirements from pyproject.toml and install them -RUN poetry config virtualenvs.create false \ - && poetry export --format requirements.txt --output /api/requirements.txt --without-hashes \ - && pip install --no-cache-dir -r /api/requirements.txt +RUN poetry config warnings.export false \ + && poetry config virtualenvs.create false +# Delete the requirements.txt related code, due to errors there, deleted --> worked??? COPY . /home/site/wwwroot \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 2797ff5e8..ec2d91948 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,11 +36,23 @@ services: # build: # context: app/workers # dockerfile: Dockerfile - # # This port was assumingly taken from https://learn.microsoft.com/en-us/azure/azure-functions/functions-deploy-container?tabs=acr%2Cbash%2Cazure-cli&pivots=programming-language-python # ports: # - 8080:80 - # env_file: - # - local.settings.json + # environment: + # IsEncrypted: 'false' + # AzureWebJobsStorage: 'UseDevelopmentStorage=true' + # FUNCTIONS_WORKER_RUNTIME: 'python' + # STORAGE_CONN_STRING: 'DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;QueueEndpoint=http://localhost:10001/devstoreaccount1;BlobEndpoint=http://localhost:10000/devstoreaccount1;' + # NLP_API_KEY: '' + # APP_URL: 'http://localhost:8000/' + # AZ_FUNCTION_KEY: '53756e8553c47897cebf6d6d730cf2e69ac4a46e' + # SCAN_REPORT_QUEUE_NAME: 'scanreports-local' + # NLP_QUEUE_NAME: 'nlpqueue-local' + # UPLOAD_QUEUE_NAME: 'uploadreports-local' + # CREATE_CONCEPTS_QUEUE_NAME: 'conceptqueue-local' + # RULES_QUEUE_NAME: 'rules-local' + # PAGE_MAX_CHARS: '30000' + # CHUNK_SIZE: '6' # # Mount the code directory # volumes: # - ./app/workers:/app/workers @@ -54,8 +66,8 @@ services: # depends_on: # - db # environment: - # - DB_PASSWORD: password - # - DB_NAME: omop + # - DB_PASSWORD=postgres (authentication fail, wrong password, changed to postgres --> worked) + # - DB_NAME=omop (database "omop" does not exist in db and error="pq: database \"omop\" does not exist here) web: image: carrot From e1378769d3eb9976edbcb61aa788e10c2b0ebf80 Mon Sep 17 00:00:00 2001 From: andrewthien Date: Tue, 6 Aug 2024 12:09:04 +0100 Subject: [PATCH 06/19] Try adding Nextjs Image --- .gitignore | 1 + app/Dockerfile | 2 +- app/entrypoint.sh | 2 -- app/next-client-app/Dockerfile | 2 +- docker-compose.yml | 26 +++++++++++++------------- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index d1be9536c..c9174ccc3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ app/api/static/javascript/react app/api/staticfiles .venv dist +api/static diff --git a/app/Dockerfile b/app/Dockerfile index 83550f366..5d8a3946d 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -26,7 +26,7 @@ RUN addgroup -q django && \ # Copy 3 files to /react-client-app directory, which can be used for building dependencies RUN mkdir /react-client-app -COPY ./react-client-app/package.json ./react-client-app/package-lock.json ./react-client-app/snowpack.config.js /react-client-app/ +COPY ./react-client-app/package.json ./react-client-app/package-lock.json ./react-client-app/snowpack.config.js /react-client-app RUN chown -R django:django /react-client-app # Install nvm as django user, and install all dependencies diff --git a/app/entrypoint.sh b/app/entrypoint.sh index 74feab38e..34e94ad91 100644 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -10,8 +10,6 @@ wait-for-it ${COCONNECT_DB_HOST}:${COCONNECT_DB_PORT} -- echo "Database is ready # Inside api directory cd /api -# Run Django migrations -python manage.py migrate # Load OMOP table and field names into the database python manage.py loaddata mapping diff --git a/app/next-client-app/Dockerfile b/app/next-client-app/Dockerfile index 481e66f40..3d9874c60 100644 --- a/app/next-client-app/Dockerfile +++ b/app/next-client-app/Dockerfile @@ -4,7 +4,7 @@ FROM node:18-alpine AS base FROM base AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat -WORKDIR /app/next-client-app +WORKDIR /app # Install dependencies based on the preferred package manager COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ diff --git a/docker-compose.yml b/docker-compose.yml index ec2d91948..30b75d7eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,19 +17,19 @@ services: - "10001:10001" - "10002:10002" - # next-client: - # image: carrot-next-client - # build: - # context: app/next-client-app - # dockerfile: Dockerfile - # ports: - # - 3000:3000 - # environment: - # - BACKEND_URL: http://web:8000 - # - BACKEND_ORIGIN: "web:8000" - # # Mount the code directory - # volumes: - # - ./app/next-client-app:/app/next-client-app + next-client: + image: carrot-next-client + build: + context: app/next-client-app + dockerfile: Dockerfile + ports: + - 3000:3000 + environment: + - BACKEND_URL=http://web:8000 + - BACKEND_ORIGIN="web:8000" + # Mount the code directory + volumes: + - ./app/next-client-app:/app/next-client-app # workers: # image: carrot-workers From 2d3c7872b65379624b5194415523486d8f8daa3f Mon Sep 17 00:00:00 2001 From: andrewthien Date: Tue, 6 Aug 2024 14:24:38 +0100 Subject: [PATCH 07/19] tesing adding Netx_url --- app/Dockerfile | 38 ++++++++++++++++++-------------------- app/entrypoint.sh | 25 ++++++++++++++++--------- docker-compose.yml | 4 +++- 3 files changed, 37 insertions(+), 30 deletions(-) diff --git a/app/Dockerfile b/app/Dockerfile index 5d8a3946d..a718d3515 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -24,18 +24,6 @@ RUN curl -y --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh RUN addgroup -q django && \ adduser --quiet --ingroup django --disabled-password django -# Copy 3 files to /react-client-app directory, which can be used for building dependencies -RUN mkdir /react-client-app -COPY ./react-client-app/package.json ./react-client-app/package-lock.json ./react-client-app/snowpack.config.js /react-client-app -RUN chown -R django:django /react-client-app - -# Install nvm as django user, and install all dependencies -USER django -WORKDIR /react-client-app -RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash -ENV NVM_DIR "/home/django/.nvm" -RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && nvm install 12.18.3 && npm install - # Create /api directory for mounting USER root RUN mkdir /api @@ -46,12 +34,12 @@ RUN chown -R django:django /api USER django ENV PATH=/home/django/.local/bin:$PATH -# Copy pyproject.toml -COPY /api/pyproject.toml /api/pyproject.toml -COPY /api/poetry.lock /api/poetry.lock +# Copy pyproject.toml and poetry.lock +COPY ./api/pyproject.toml /api/pyproject.toml +COPY ./api/poetry.lock /api/poetry.lock # Copy shared package -COPY /shared /shared +COPY ./shared /shared # Install Poetry RUN pip install poetry @@ -61,18 +49,28 @@ RUN poetry config virtualenvs.create false \ && poetry export --format requirements.txt --output /api/requirements.txt --without-hashes \ && pip install --no-cache-dir -r /api/requirements.txt -# Copy react-client-app/src and react-client-app/.storybook directories +# Copy react-client-app directory +USER root +COPY ./react-client-app /react-client-app +RUN chown -R django:django /react-client-app + +# Install nvm as django user USER django -COPY ./react-client-app/src /react-client-app/src -COPY ./react-client-app/.storybook /react-client-app/.storybook WORKDIR /react-client-app +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash +ENV NVM_DIR "/home/django/.nvm" +RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && nvm install 12.18.3 && npm install # Copy entrypoint as root, elevate it to executable, then give it over to django user USER root COPY ./entrypoint.sh /entrypoint.sh RUN chmod u+x /entrypoint.sh RUN chown -R django:django /entrypoint.sh + +# Set the working directory to /api +WORKDIR /api +COPY ./api /api ENTRYPOINT ["/entrypoint.sh"] # Return to django user to run the container as this user by default -USER django +USER django \ No newline at end of file diff --git a/app/entrypoint.sh b/app/entrypoint.sh index 34e94ad91..c3bf22b45 100644 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -2,26 +2,33 @@ # Run npm build export PATH=$PATH:/home/django/.nvm/versions/node/v12.18.3/bin +cd /react-client-app npm run build # Wait until DB is available wait-for-it ${COCONNECT_DB_HOST}:${COCONNECT_DB_PORT} -- echo "Database is ready! Listening on ${COCONNECT_DB_HOST}:${COCONNECT_DB_PORT}" -# Inside api directory cd /api - # Load OMOP table and field names into the database -python manage.py loaddata mapping - -# Create superuser -python manage.py createsuperuser +# python manage.py loaddata mapping +# if [ $? -ne 0 ]; then +# echo "Error loading mapping data" +# exit 1 +# fi + +# # Create superuser +# python manage.py createsuperuser +# if [ $? -ne 0 ]; then +# echo "Error creating superuser" +# exit 1 +# fi # Collect static files for serving rm -rf staticfiles mkdir staticfiles -python /api/manage.py collectstatic -python /api/manage.py migrate +python manage.py collectstatic +python manage.py migrate # Set tmp dir to be in-memory for speed. Pass logs to stdout/err as Docker will expect them there -gunicorn --config gunicorn.conf.py --worker-tmp-dir /dev/shm --timeout 600 --log-file=- --bind :8000 --workers 3 config.wsgi:application --reload +gunicorn --config gunicorn.conf.py --worker-tmp-dir /dev/shm --timeout 600 --log-file=- --bind :8000 --workers 3 config.wsgi:application --reload \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 30b75d7eb..4ab4b075a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -78,8 +78,10 @@ services: - 8000:8000 env_file: - .env + environment: + - NEXTJS_URL=http://localhost:3000 volumes: - - $PWD/api:/api + - ./app/api:/api depends_on: - db - azurite From cf7be4c418b844437203aeab9d76231feb534e25 Mon Sep 17 00:00:00 2001 From: andrewthien Date: Tue, 6 Aug 2024 15:57:11 +0100 Subject: [PATCH 08/19] add omop-lite, and environment variables --- docker-compose.yml | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4ab4b075a..b332f7226 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,7 @@ services: - 5432:5432 environment: - POSTGRES_PASSWORD=postgres + - POSTGRES_DB=omop azurite: image: mcr.microsoft.com/azure-storage/azurite @@ -59,15 +60,15 @@ services: # depends_on: # - web - # omop-lite: - # image: ghcr.io/andyrae/omop-lite - # volumes: - # - ./vocabs:/vocabs - # depends_on: - # - db - # environment: - # - DB_PASSWORD=postgres (authentication fail, wrong password, changed to postgres --> worked) - # - DB_NAME=omop (database "omop" does not exist in db and error="pq: database \"omop\" does not exist here) + omop-lite: + image: ghcr.io/andyrae/omop-lite + volumes: + - ./vocabs:/vocabs + depends_on: + - db + environment: + - DB_PASSWORD=postgres + - DB_NAME=omop web: image: carrot @@ -76,10 +77,26 @@ services: dockerfile: Dockerfile ports: - 8000:8000 + # will remove this after doing the workers containerising env_file: - .env environment: - - NEXTJS_URL=http://localhost:3000 + - NEXTJS_URL=http://next-client:3000 + - DJANGO_SUPERUSER_USERNAME=admin + - DJANGO_SUPERUSER_EMAIL=admin@example.com + - DJANGO_SUPERUSER_PASSWORD=password + - ALLOWED_HOSTS=['localhost', '127.0.0.1','web'] + - COCONNECT_DB_ENGINE=django.db.backends.postgresql + - COCONNECT_DB_HOST=db + - COCONNECT_DB_PORT=5432 + - COCONNECT_DB_NAME=omop + - COCONNECT_DB_USER=postgres + - COCONNECT_DB_PASSWORD=postgres + - UPLOAD_ONLY=false + - ENABLE_PROXY=true + - CCOM_APP_URL= http://localhost:8000 + - AZ_FUNCTION_USER=admin + - DEBUG=True volumes: - ./app/api:/api depends_on: From fef5bcfa86f74fddff98df96d91e0264fda01789 Mon Sep 17 00:00:00 2001 From: andrewthien Date: Tue, 6 Aug 2024 15:57:30 +0100 Subject: [PATCH 09/19] adding create-super-user and loading mapping data --- app/entrypoint.sh | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/app/entrypoint.sh b/app/entrypoint.sh index c3bf22b45..2c3d4fdc6 100644 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -11,18 +11,28 @@ wait-for-it ${COCONNECT_DB_HOST}:${COCONNECT_DB_PORT} -- echo "Database is ready cd /api # Load OMOP table and field names into the database -# python manage.py loaddata mapping -# if [ $? -ne 0 ]; then -# echo "Error loading mapping data" -# exit 1 -# fi - -# # Create superuser -# python manage.py createsuperuser -# if [ $? -ne 0 ]; then -# echo "Error creating superuser" -# exit 1 -# fi +python manage.py loaddata mapping +if [ $? -ne 0 ]; then + echo "Error loading mapping data" + exit 1 +fi + +# Check if a superuser named 'admin' exists +echo "Checking for existing superuser named 'admin'..." +python manage.py shell -c "from django.contrib.auth import get_user_model; User = get_user_model(); exit(0) if User.objects.filter(username='admin', is_superuser=True).exists() else exit(1)" +if [ $? -eq 0 ]; then + echo "Superuser 'admin' already exists. Skipping createsuperuser step." +else + echo "Creating superuser..." + python manage.py createsuperuser --noinput --username $DJANGO_SUPERUSER_USERNAME --email $DJANGO_SUPERUSER_EMAIL + if [ $? -ne 0 ]; then + echo "Error creating superuser" + exit 1 + fi + + # Set superuser password + echo "from django.contrib.auth import get_user_model; User = get_user_model(); user = User.objects.get(username='$DJANGO_SUPERUSER_USERNAME'); user.set_password('$DJANGO_SUPERUSER_PASSWORD'); user.save()" | python manage.py shell +fi # Collect static files for serving rm -rf staticfiles From 35f01bc7768491e93ae8c273bcaf6f6bad5d3d06 Mon Sep 17 00:00:00 2001 From: andrewthien Date: Tue, 6 Aug 2024 15:57:49 +0100 Subject: [PATCH 10/19] update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c9174ccc3..9b632d222 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ app/api/staticfiles .venv dist api/static +vocabs From 0398064b0b529b2e3721379750c78d13f7c25abf Mon Sep 17 00:00:00 2001 From: andrewthien Date: Tue, 6 Aug 2024 17:14:09 +0100 Subject: [PATCH 11/19] fix icon size --- app/next-client-app/components/core/sidebar.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/next-client-app/components/core/sidebar.tsx b/app/next-client-app/components/core/sidebar.tsx index 53372f017..87e02842c 100644 --- a/app/next-client-app/components/core/sidebar.tsx +++ b/app/next-client-app/components/core/sidebar.tsx @@ -74,12 +74,11 @@ export function Sidebar({ userName }: { userName: string }) {
carrot-logo Carrot
@@ -147,12 +146,11 @@ export function Sidebar({ userName }: { userName: string }) {
carrot-logo Carrot
From d99bb3f931469cdd1b432765f256778be9300f4b Mon Sep 17 00:00:00 2001 From: andrewthien Date: Tue, 6 Aug 2024 17:15:45 +0100 Subject: [PATCH 12/19] update the messages --- app/entrypoint.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/entrypoint.sh b/app/entrypoint.sh index 2c3d4fdc6..e19cffe7d 100644 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -10,7 +10,7 @@ wait-for-it ${COCONNECT_DB_HOST}:${COCONNECT_DB_PORT} -- echo "Database is ready cd /api -# Load OMOP table and field names into the database +echo "Loading mapping data" python manage.py loaddata mapping if [ $? -ne 0 ]; then echo "Error loading mapping data" @@ -18,10 +18,9 @@ if [ $? -ne 0 ]; then fi # Check if a superuser named 'admin' exists -echo "Checking for existing superuser named 'admin'..." python manage.py shell -c "from django.contrib.auth import get_user_model; User = get_user_model(); exit(0) if User.objects.filter(username='admin', is_superuser=True).exists() else exit(1)" if [ $? -eq 0 ]; then - echo "Superuser 'admin' already exists. Skipping createsuperuser step." + echo "Superuser already exists. Skipping creating superuser..." else echo "Creating superuser..." python manage.py createsuperuser --noinput --username $DJANGO_SUPERUSER_USERNAME --email $DJANGO_SUPERUSER_EMAIL From bb09d1f961aa40b103a04bbc1257321415420015 Mon Sep 17 00:00:00 2001 From: andrewthien Date: Tue, 6 Aug 2024 17:16:25 +0100 Subject: [PATCH 13/19] Complete environment vars for web and testing compose watching function --- docker-compose.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b332f7226..802232b68 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,8 +29,17 @@ services: - BACKEND_URL=http://web:8000 - BACKEND_ORIGIN="web:8000" # Mount the code directory - volumes: - - ./app/next-client-app:/app/next-client-app + # volumes: + # - ./app/next-client-app:/app/next-client-app + develop: + watch: + - action: sync + path: app/next-client-app + target: app/next-client-app + ignore: + - node_modules/ + - action: rebuild + path: package-lock.json # workers: # image: carrot-workers @@ -77,9 +86,6 @@ services: dockerfile: Dockerfile ports: - 8000:8000 - # will remove this after doing the workers containerising - env_file: - - .env environment: - NEXTJS_URL=http://next-client:3000 - DJANGO_SUPERUSER_USERNAME=admin @@ -92,11 +98,18 @@ services: - COCONNECT_DB_NAME=omop - COCONNECT_DB_USER=postgres - COCONNECT_DB_PASSWORD=postgres + - COCONNECT_DB_AUTH_TOKEN= - UPLOAD_ONLY=false - ENABLE_PROXY=true - CCOM_APP_URL= http://localhost:8000 - AZ_FUNCTION_USER=admin - DEBUG=True + - NLP_QUEUE_NAME=nlpqueue-local + - SCAN_REPORT_QUEUE_NAME=scanreports-local + - UPLOAD_QUEUE_NAME=uploadreports-local + - CREATE_CONCEPTS_QUEUE_NAME=conceptqueue-local + - SECRET_KEY=secret + - AZURE_ACCOUNT_NAME=devstoreaccount1 volumes: - ./app/api:/api depends_on: From d57519bd07fcafab3b6f74fb3779cb3b7031e9a9 Mon Sep 17 00:00:00 2001 From: andrewthien Date: Wed, 7 Aug 2024 12:09:11 +0100 Subject: [PATCH 14/19] Add sharp and update Dockerfiles of Next --- app/next-client-app/.dockerignore | 4 +- app/next-client-app/Dockerfile | 2 +- app/next-client-app/package-lock.json | 498 +++++++++++++++++++++++++- app/next-client-app/package.json | 1 + 4 files changed, 502 insertions(+), 3 deletions(-) diff --git a/app/next-client-app/.dockerignore b/app/next-client-app/.dockerignore index 72e9aa425..7680c8d25 100644 --- a/app/next-client-app/.dockerignore +++ b/app/next-client-app/.dockerignore @@ -4,4 +4,6 @@ node_modules npm-debug.log README.md .next -.git \ No newline at end of file +.git +!.next/static +!.next/standalone \ No newline at end of file diff --git a/app/next-client-app/Dockerfile b/app/next-client-app/Dockerfile index 3d9874c60..9be2006bb 100644 --- a/app/next-client-app/Dockerfile +++ b/app/next-client-app/Dockerfile @@ -50,7 +50,7 @@ USER nextjs EXPOSE 3000 -ENV PORT 3000 +ENV PORT=3000 # server.js is created by next build from the standalone output # https://nextjs.org/docs/pages/api-reference/next-config-js/output diff --git a/app/next-client-app/package-lock.json b/app/next-client-app/package-lock.json index 5bccf8506..b72824ea0 100644 --- a/app/next-client-app/package-lock.json +++ b/app/next-client-app/package-lock.json @@ -36,6 +36,7 @@ "react-dom": "^18", "react-select": "^5.8.0", "react-tooltip": "^5.26.4", + "sharp": "^0.33.4", "sonner": "^1.4.41", "tailwind-merge": "^2.2.2", "tailwindcss-animate": "^1.0.7", @@ -319,6 +320,15 @@ "node": ">=6.9.0" } }, + "node_modules/@emnapi/runtime": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.2.0.tgz", + "integrity": "sha512-bV21/9LQmcQeCPEg3BDFtvwL6cwiTMksYNWQQ4KOxCZikEGalWtenoZ0wCiukJINlGCIi2KXx01g4FoH/LxpzQ==", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@emotion/babel-plugin": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.12.0.tgz", @@ -547,6 +557,412 @@ "deprecated": "Use @eslint/object-schema instead", "dev": true }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.4.tgz", + "integrity": "sha512-p0suNqXufJs9t3RqLBO6vvrgr5OhgbWp76s5gTRvdmxmuv9E1rcaqGUsl3l4mKVmXPkTkTErXediAui4x+8PSA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.0.2" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.4.tgz", + "integrity": "sha512-0l7yRObwtTi82Z6ebVI2PnHT8EB2NxBgpK2MiKJZJ7cz32R4lxd001ecMhzzsZig3Yv9oclvqqdV93jo9hy+Dw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.0.2" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.2.tgz", + "integrity": "sha512-tcK/41Rq8IKlSaKRCCAuuY3lDJjQnYIW1UXU1kxcEKrfL8WR7N6+rzNoOxoQRJWTAECuKwgAHnPvqXGN8XfkHA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "macos": ">=11", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.2.tgz", + "integrity": "sha512-Ofw+7oaWa0HiiMiKWqqaZbaYV3/UGL2wAPeLuJTx+9cXpCRdvQhCLG0IH8YGwM0yGWGLpsF4Su9vM1o6aer+Fw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "macos": ">=10.13", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.2.tgz", + "integrity": "sha512-iLWCvrKgeFoglQxdEwzu1eQV04o8YeYGFXtfWU26Zr2wWT3q3MTzC+QTCO3ZQfWd3doKHT4Pm2kRmLbupT+sZw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.28", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.2.tgz", + "integrity": "sha512-x7kCt3N00ofFmmkkdshwj3vGPCnmiDh7Gwnd4nUwZln2YjqPxV1NlTyZOvoDWdKQVDL911487HOueBvrpflagw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.2.tgz", + "integrity": "sha512-cmhQ1J4qVhfmS6szYW7RT+gLJq9dH2i4maq+qyXayUSn9/3iY2ZeWpbAgSpSVbV2E1JUL2Gg7pwnYQ1h8rQIog==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.28", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.2.tgz", + "integrity": "sha512-E441q4Qdb+7yuyiADVi5J+44x8ctlrqn8XgkDTwr4qPJzWkaHwD489iZ4nGDgcuya4iMN3ULV6NwbhRZJ9Z7SQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.2.tgz", + "integrity": "sha512-3CAkndNpYUrlDqkCM5qhksfE+qSIREVpyoeHIU6jd48SJZViAmznoQQLAv4hVXF7xyUB9zf+G++e2v1ABjCbEQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.2.tgz", + "integrity": "sha512-VI94Q6khIHqHWNOh6LLdm9s2Ry4zdjWJwH56WoiJU7NTeDwyApdZZ8c+SADC8OH98KWNQXnE01UdJ9CSfZvwZw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.4.tgz", + "integrity": "sha512-2800clwVg1ZQtxwSoTlHvtm9ObgAax7V6MTAB/hDT945Tfyy3hVkmiHpeLPCKYqYR1Gcmv1uDZ3a4OFwkdBL7Q==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.0.2" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.4.tgz", + "integrity": "sha512-h3RAL3siQoyzSoH36tUeS0PDmb5wINKGYzcLB5C6DIiAn2F3udeFAum+gj8IbA/82+8RGCTn7XW8WTFnqag4tQ==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.31", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.0.2" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.4.tgz", + "integrity": "sha512-GoR++s0XW9DGVi8SUGQ/U4AeIzLdNjHka6jidVwapQ/JebGVQIpi52OdyxCNVRE++n1FCLzjDovJNozif7w/Aw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.0.2" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.4.tgz", + "integrity": "sha512-nhr1yC3BlVrKDTl6cO12gTpXMl4ITBUZieehFvMntlCXFzH2bvKG76tBL2Y/OqhupZt81pR7R+Q5YhJxW0rGgQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.0.2" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.4.tgz", + "integrity": "sha512-uCPTku0zwqDmZEOi4ILyGdmW76tH7dm8kKlOIV1XC5cLyJ71ENAAqarOHQh0RLfpIpbV5KOpXzdU6XkJtS0daw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.0.2" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.33.4.tgz", + "integrity": "sha512-Bmmauh4sXUsUqkleQahpdNXKvo+wa1V9KhT2pDA4VJGKwnKMJXiSTGphn0gnJrlooda0QxCtXc6RX1XAU6hMnQ==", + "cpu": [ + "wasm32" + ], + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.1.1" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.4.tgz", + "integrity": "sha512-99SJ91XzUhYHbx7uhK3+9Lf7+LjwMGQZMDlO/E/YVJ7Nc3lyDFZPGhjwiYdctoH2BOzW9+TnfqcaMKt0jHLdqw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.4.tgz", + "integrity": "sha512-3QLocdTRVIrFNye5YocZl+KKpYKP+fksi1QhmOArgx7GyhIbQp/WrJRu176jm8IxromS7RIkzMiMINVdBtC8Aw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -2868,6 +3284,18 @@ } } }, + "node_modules/color": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", + "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", + "dependencies": { + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + }, + "engines": { + "node": ">=12.5.0" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2884,6 +3312,15 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/color-string": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", + "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", + "dependencies": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, "node_modules/commander": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", @@ -3109,6 +3546,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/detect-libc": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", + "engines": { + "node": ">=8" + } + }, "node_modules/detect-node-es": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/detect-node-es/-/detect-node-es-1.1.0.tgz", @@ -6082,7 +6527,6 @@ "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", - "dev": true, "bin": { "semver": "bin/semver.js" }, @@ -6122,6 +6566,45 @@ "node": ">= 0.4" } }, + "node_modules/sharp": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.4.tgz", + "integrity": "sha512-7i/dt5kGl7qR4gwPRD2biwD2/SvBn3O04J77XKFgL2OnZtQw+AG9wnuS/csmu80nPRHLYE9E41fyEiG8nhH6/Q==", + "hasInstallScript": true, + "dependencies": { + "color": "^4.2.3", + "detect-libc": "^2.0.3", + "semver": "^7.6.0" + }, + "engines": { + "libvips": ">=8.15.2", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.33.4", + "@img/sharp-darwin-x64": "0.33.4", + "@img/sharp-libvips-darwin-arm64": "1.0.2", + "@img/sharp-libvips-darwin-x64": "1.0.2", + "@img/sharp-libvips-linux-arm": "1.0.2", + "@img/sharp-libvips-linux-arm64": "1.0.2", + "@img/sharp-libvips-linux-s390x": "1.0.2", + "@img/sharp-libvips-linux-x64": "1.0.2", + "@img/sharp-libvips-linuxmusl-arm64": "1.0.2", + "@img/sharp-libvips-linuxmusl-x64": "1.0.2", + "@img/sharp-linux-arm": "0.33.4", + "@img/sharp-linux-arm64": "0.33.4", + "@img/sharp-linux-s390x": "0.33.4", + "@img/sharp-linux-x64": "0.33.4", + "@img/sharp-linuxmusl-arm64": "0.33.4", + "@img/sharp-linuxmusl-x64": "0.33.4", + "@img/sharp-wasm32": "0.33.4", + "@img/sharp-win32-ia32": "0.33.4", + "@img/sharp-win32-x64": "0.33.4" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -6170,6 +6653,19 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", + "dependencies": { + "is-arrayish": "^0.3.1" + } + }, + "node_modules/simple-swizzle/node_modules/is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", diff --git a/app/next-client-app/package.json b/app/next-client-app/package.json index facd47b3c..cc71962df 100644 --- a/app/next-client-app/package.json +++ b/app/next-client-app/package.json @@ -37,6 +37,7 @@ "react-dom": "^18", "react-select": "^5.8.0", "react-tooltip": "^5.26.4", + "sharp": "^0.33.4", "sonner": "^1.4.41", "tailwind-merge": "^2.2.2", "tailwindcss-animate": "^1.0.7", From a2ab90f599a71cb6749ce1d305d6a1dccfa33a7f Mon Sep 17 00:00:00 2001 From: andrewthien Date: Wed, 7 Aug 2024 12:09:58 +0100 Subject: [PATCH 15/19] Cleaning up --- app/Dockerfile | 1 - app/entrypoint.sh | 23 ----------------------- docker-compose.yml | 47 +++------------------------------------------- 3 files changed, 3 insertions(+), 68 deletions(-) diff --git a/app/Dockerfile b/app/Dockerfile index a718d3515..e26e4c0b3 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -69,7 +69,6 @@ RUN chown -R django:django /entrypoint.sh # Set the working directory to /api WORKDIR /api -COPY ./api /api ENTRYPOINT ["/entrypoint.sh"] # Return to django user to run the container as this user by default diff --git a/app/entrypoint.sh b/app/entrypoint.sh index e19cffe7d..a9ae45595 100644 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -10,29 +10,6 @@ wait-for-it ${COCONNECT_DB_HOST}:${COCONNECT_DB_PORT} -- echo "Database is ready cd /api -echo "Loading mapping data" -python manage.py loaddata mapping -if [ $? -ne 0 ]; then - echo "Error loading mapping data" - exit 1 -fi - -# Check if a superuser named 'admin' exists -python manage.py shell -c "from django.contrib.auth import get_user_model; User = get_user_model(); exit(0) if User.objects.filter(username='admin', is_superuser=True).exists() else exit(1)" -if [ $? -eq 0 ]; then - echo "Superuser already exists. Skipping creating superuser..." -else - echo "Creating superuser..." - python manage.py createsuperuser --noinput --username $DJANGO_SUPERUSER_USERNAME --email $DJANGO_SUPERUSER_EMAIL - if [ $? -ne 0 ]; then - echo "Error creating superuser" - exit 1 - fi - - # Set superuser password - echo "from django.contrib.auth import get_user_model; User = get_user_model(); user = User.objects.get(username='$DJANGO_SUPERUSER_USERNAME'); user.set_password('$DJANGO_SUPERUSER_PASSWORD'); user.save()" | python manage.py shell -fi - # Collect static files for serving rm -rf staticfiles mkdir staticfiles diff --git a/docker-compose.yml b/docker-compose.yml index 802232b68..a7a6e24ec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -name: carrot-mapper-dev-test +name: carrot-mapper-dev-v2 services: db: @@ -28,46 +28,8 @@ services: environment: - BACKEND_URL=http://web:8000 - BACKEND_ORIGIN="web:8000" - # Mount the code directory - # volumes: - # - ./app/next-client-app:/app/next-client-app - develop: - watch: - - action: sync - path: app/next-client-app - target: app/next-client-app - ignore: - - node_modules/ - - action: rebuild - path: package-lock.json - - # workers: - # image: carrot-workers - # build: - # context: app/workers - # dockerfile: Dockerfile - # ports: - # - 8080:80 - # environment: - # IsEncrypted: 'false' - # AzureWebJobsStorage: 'UseDevelopmentStorage=true' - # FUNCTIONS_WORKER_RUNTIME: 'python' - # STORAGE_CONN_STRING: 'DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;QueueEndpoint=http://localhost:10001/devstoreaccount1;BlobEndpoint=http://localhost:10000/devstoreaccount1;' - # NLP_API_KEY: '' - # APP_URL: 'http://localhost:8000/' - # AZ_FUNCTION_KEY: '53756e8553c47897cebf6d6d730cf2e69ac4a46e' - # SCAN_REPORT_QUEUE_NAME: 'scanreports-local' - # NLP_QUEUE_NAME: 'nlpqueue-local' - # UPLOAD_QUEUE_NAME: 'uploadreports-local' - # CREATE_CONCEPTS_QUEUE_NAME: 'conceptqueue-local' - # RULES_QUEUE_NAME: 'rules-local' - # PAGE_MAX_CHARS: '30000' - # CHUNK_SIZE: '6' - # # Mount the code directory - # volumes: - # - ./app/workers:/app/workers - # depends_on: - # - web + volumes: + - ./app/next-client-app:/app/next-client-app omop-lite: image: ghcr.io/andyrae/omop-lite @@ -88,9 +50,6 @@ services: - 8000:8000 environment: - NEXTJS_URL=http://next-client:3000 - - DJANGO_SUPERUSER_USERNAME=admin - - DJANGO_SUPERUSER_EMAIL=admin@example.com - - DJANGO_SUPERUSER_PASSWORD=password - ALLOWED_HOSTS=['localhost', '127.0.0.1','web'] - COCONNECT_DB_ENGINE=django.db.backends.postgresql - COCONNECT_DB_HOST=db From 1a9fcf10cf306e43efacbfb3b3294988bf484280 Mon Sep 17 00:00:00 2001 From: andrewthien Date: Wed, 7 Aug 2024 12:26:20 +0100 Subject: [PATCH 16/19] Deep clean --- .dockerignore | 2 +- app/Dockerfile | 2 +- app/entrypoint.sh | 2 +- app/next-client-app/.dockerignore | 2 +- app/next-client-app/Dockerfile | 2 +- app/workers/.funcignore | 1 - app/workers/.gitignore | 48 ----------------------------- app/workers/.vscode/extensions.json | 5 --- app/workers/Dockerfile | 23 -------------- app/workers/function_app.py | 6 ---- 10 files changed, 5 insertions(+), 88 deletions(-) delete mode 100644 app/workers/.gitignore delete mode 100644 app/workers/.vscode/extensions.json delete mode 100644 app/workers/Dockerfile delete mode 100644 app/workers/function_app.py diff --git a/.dockerignore b/.dockerignore index 4c3724d67..e3759a277 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,2 @@ react-client-app/node_modules -next-client-app/node_modules \ No newline at end of file +next-client-app/node_modules diff --git a/app/Dockerfile b/app/Dockerfile index e26e4c0b3..703f7f59b 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -72,4 +72,4 @@ WORKDIR /api ENTRYPOINT ["/entrypoint.sh"] # Return to django user to run the container as this user by default -USER django \ No newline at end of file +USER django diff --git a/app/entrypoint.sh b/app/entrypoint.sh index a9ae45595..540131128 100644 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -17,4 +17,4 @@ python manage.py collectstatic python manage.py migrate # Set tmp dir to be in-memory for speed. Pass logs to stdout/err as Docker will expect them there -gunicorn --config gunicorn.conf.py --worker-tmp-dir /dev/shm --timeout 600 --log-file=- --bind :8000 --workers 3 config.wsgi:application --reload \ No newline at end of file +gunicorn --config gunicorn.conf.py --worker-tmp-dir /dev/shm --timeout 600 --log-file=- --bind :8000 --workers 3 config.wsgi:application --reload diff --git a/app/next-client-app/.dockerignore b/app/next-client-app/.dockerignore index 7680c8d25..0b48bc7ca 100644 --- a/app/next-client-app/.dockerignore +++ b/app/next-client-app/.dockerignore @@ -6,4 +6,4 @@ README.md .next .git !.next/static -!.next/standalone \ No newline at end of file +!.next/standalone diff --git a/app/next-client-app/Dockerfile b/app/next-client-app/Dockerfile index 9be2006bb..b71eed915 100644 --- a/app/next-client-app/Dockerfile +++ b/app/next-client-app/Dockerfile @@ -54,4 +54,4 @@ ENV PORT=3000 # server.js is created by next build from the standalone output # https://nextjs.org/docs/pages/api-reference/next-config-js/output -CMD HOSTNAME="0.0.0.0" node server.js \ No newline at end of file +CMD HOSTNAME="0.0.0.0" node server.js diff --git a/app/workers/.funcignore b/app/workers/.funcignore index 8b1378917..e69de29bb 100644 --- a/app/workers/.funcignore +++ b/app/workers/.funcignore @@ -1 +0,0 @@ - diff --git a/app/workers/.gitignore b/app/workers/.gitignore deleted file mode 100644 index f15ac3fc6..000000000 --- a/app/workers/.gitignore +++ /dev/null @@ -1,48 +0,0 @@ -bin -obj -csx -.vs -edge -Publish - -*.user -*.suo -*.cscfg -*.Cache -project.lock.json - -/packages -/TestResults - -/tools/NuGet.exe -/App_Data -/secrets -/data -.secrets -appsettings.json -local.settings.json - -node_modules -dist - -# Local python packages -.python_packages/ - -# Python Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# Azurite artifacts -__blobstorage__ -__queuestorage__ -__azurite_db*__.json \ No newline at end of file diff --git a/app/workers/.vscode/extensions.json b/app/workers/.vscode/extensions.json deleted file mode 100644 index dde673dcd..000000000 --- a/app/workers/.vscode/extensions.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "recommendations": [ - "ms-azuretools.vscode-azurefunctions" - ] -} \ No newline at end of file diff --git a/app/workers/Dockerfile b/app/workers/Dockerfile deleted file mode 100644 index 3439b924c..000000000 --- a/app/workers/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -# To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/python:4-python3.11-appservice -FROM mcr.microsoft.com/azure-functions/python:4-python3.11 - -ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ - AzureFunctionsJobHost__Logging__Console__IsEnabled=true \ - AzureFunctionsWebHost__hostid=carrot-worker - -# Set a working directory -WORKDIR /app/workers - -# Copy pyproject.toml and poetry.lock -COPY pyproject.toml poetry.lock ./ - -# Install Poetry -RUN pip install poetry - -# Export requirements from pyproject.toml and install them -RUN poetry config warnings.export false \ - && poetry config virtualenvs.create false -# Delete the requirements.txt related code, due to errors there, deleted --> worked??? - -COPY . /home/site/wwwroot \ No newline at end of file diff --git a/app/workers/function_app.py b/app/workers/function_app.py deleted file mode 100644 index e9b5526d2..000000000 --- a/app/workers/function_app.py +++ /dev/null @@ -1,6 +0,0 @@ -import azure.functions as func -import datetime -import json -import logging - -app = func.FunctionApp() \ No newline at end of file From 9c340fc7b47635cdb3f6365fb616346d5d22ccd5 Mon Sep 17 00:00:00 2001 From: andrewthien Date: Wed, 7 Aug 2024 12:28:32 +0100 Subject: [PATCH 17/19] Deep clean 2 --- app/workers/.dockerignore | 1 - app/workers/.funcignore | 0 2 files changed, 1 deletion(-) delete mode 100644 app/workers/.dockerignore delete mode 100644 app/workers/.funcignore diff --git a/app/workers/.dockerignore b/app/workers/.dockerignore deleted file mode 100644 index 1927772bc..000000000 --- a/app/workers/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -local.settings.json \ No newline at end of file diff --git a/app/workers/.funcignore b/app/workers/.funcignore deleted file mode 100644 index e69de29bb..000000000 From 159fdae56e51640f8ea038fdc18811d1cd0019ad Mon Sep 17 00:00:00 2001 From: andrewthien Date: Thu, 8 Aug 2024 10:20:48 +0100 Subject: [PATCH 18/19] modify on requested --- app/entrypoint.sh | 5 ++--- docker-compose.yml | 10 +++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/app/entrypoint.sh b/app/entrypoint.sh index 540131128..1eaab3a36 100644 --- a/app/entrypoint.sh +++ b/app/entrypoint.sh @@ -2,7 +2,6 @@ # Run npm build export PATH=$PATH:/home/django/.nvm/versions/node/v12.18.3/bin -cd /react-client-app npm run build # Wait until DB is available @@ -13,8 +12,8 @@ cd /api # Collect static files for serving rm -rf staticfiles mkdir staticfiles -python manage.py collectstatic -python manage.py migrate +python /api/manage.py collectstatic +python /api/manage.py migrate # Set tmp dir to be in-memory for speed. Pass logs to stdout/err as Docker will expect them there gunicorn --config gunicorn.conf.py --worker-tmp-dir /dev/shm --timeout 600 --log-file=- --bind :8000 --workers 3 config.wsgi:application --reload diff --git a/docker-compose.yml b/docker-compose.yml index a7a6e24ec..3e9c2a291 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: - BACKEND_URL=http://web:8000 - BACKEND_ORIGIN="web:8000" volumes: - - ./app/next-client-app:/app/next-client-app + - ./app/next-client-app:/next-client-app omop-lite: image: ghcr.io/andyrae/omop-lite @@ -57,18 +57,14 @@ services: - COCONNECT_DB_NAME=omop - COCONNECT_DB_USER=postgres - COCONNECT_DB_PASSWORD=postgres - - COCONNECT_DB_AUTH_TOKEN= - - UPLOAD_ONLY=false - ENABLE_PROXY=true - - CCOM_APP_URL= http://localhost:8000 - AZ_FUNCTION_USER=admin - DEBUG=True - - NLP_QUEUE_NAME=nlpqueue-local - - SCAN_REPORT_QUEUE_NAME=scanreports-local - UPLOAD_QUEUE_NAME=uploadreports-local - - CREATE_CONCEPTS_QUEUE_NAME=conceptqueue-local - SECRET_KEY=secret - AZURE_ACCOUNT_NAME=devstoreaccount1 + - AZ_URL=http://workers:7071 + - AZ_RULES_NAME=RulesOrchestrator volumes: - ./app/api:/api depends_on: From 777768c78ea8c7ef159eb57a76d01bc21493819a Mon Sep 17 00:00:00 2001 From: andrewthien Date: Fri, 9 Aug 2024 09:29:39 +0100 Subject: [PATCH 19/19] change back the docker-compose name --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3e9c2a291..576cbcc08 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -name: carrot-mapper-dev-v2 +name: carrot-mapper-dev services: db: