diff --git a/containers/ecr-viewer/seed-scripts/docker-compose-seed.yml b/containers/ecr-viewer/seed-scripts/docker-compose-seed.yml index ab73ba224..e1be74d6a 100644 --- a/containers/ecr-viewer/seed-scripts/docker-compose-seed.yml +++ b/containers/ecr-viewer/seed-scripts/docker-compose-seed.yml @@ -4,6 +4,7 @@ include: - ../docker-compose.yml services: fhir-converter-service: + platform: linux/amd64 build: context: ../../fhir-converter/ ports: diff --git a/containers/fhir-converter/Dockerfile b/containers/fhir-converter/Dockerfile index fc77e36cc..05c8074ac 100644 --- a/containers/fhir-converter/Dockerfile +++ b/containers/fhir-converter/Dockerfile @@ -1,39 +1,31 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build # Download FHIR-Converter -RUN git clone https://github.com/skylight-hq/FHIR-Converter.git --branch v7.0-skylight-9 --single-branch /build/FHIR-Converter +RUN git clone https://github.com/skylight-hq/FHIR-Converter.git --branch v7.0-skylight-11 --single-branch /build/FHIR-Converter WORKDIR /build/FHIR-Converter -RUN pwd && ls -la - RUN echo test > src/Microsoft.Health.Fhir.TemplateManagement.UnitTests/TestData/DecompressedFiles/VXU_V04.liquid RUN if [ -f src/Microsoft.Health.Fhir.TemplateManagement.UnitTests/TestData/DecompressedFiles/.wh.VXU_V04.liquid ]; then rm src/Microsoft.Health.Fhir.TemplateManagement.UnitTests/TestData/DecompressedFiles/.wh.VXU_V04.liquid; fi -RUN mkdir bin && \ - wget https://github.com/deislabs/oras/releases/download/v0.12.0/oras_0.12.0_windows_amd64.tar.gz -O ./bin/oras.tar.gz && \ - tar -xvf ./bin/oras.tar.gz -C ./bin # Build Microsoft FHIR Converter -RUN dotnet build -c Release -o output +RUN dotnet clean +RUN dotnet publish \ + src/Microsoft.Health.Fhir.Liquid.Converter.Tool/Microsoft.Health.Fhir.Liquid.Converter.Tool.csproj \ + -c Release \ + -r linux-x64 \ + --self-contained true \ + -o output -FROM mcr.microsoft.com/dotnet/runtime:6.0 AS runtime +# Set up python Server +FROM python:3.10-slim AS runtime # Copy FHIR-Converter binary from build stage COPY --from=build /build/FHIR-Converter/output /build/FHIR-Converter/output COPY --from=build /build/FHIR-Converter/data/Templates /build/FHIR-Converter/data/Templates -ENV PYTHONUNBUFFERED=1 - -# Install python via pyenv -RUN apt-get update && apt-get install -y curl git jq build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev -RUN curl https://pyenv.run | bash -RUN export PYENV_ROOT="$HOME/.pyenv" -RUN export PATH="$PYENV_ROOT/bin:$PATH" -RUN eval "$(pyenv init -)" -RUN /root/.pyenv/bin/pyenv install 3.10.13 -RUN /root/.pyenv/bin/pyenv global 3.10.13 - -RUN /root/.pyenv/shims/pip install --no-cache --upgrade pip setuptools +# # Install python via pyenv +RUN apt-get update && apt-get install -y curl jq libicu-dev # Get an up to date copy of active rxnorm codes and names RUN rm /build/FHIR-Converter/output/rxnorm.csv @@ -44,8 +36,11 @@ RUN curl 'https://rxnav.nlm.nih.gov/REST/allstatus.json?status=active' \ # Install requirements WORKDIR /code +# Set --build-arg CACHBUSTSERVICE= to only invalidate the python code installation +ARG CACHEBUSTSERVICE=1 + COPY requirements.txt . -RUN /root/.pyenv/shims/pip install -r requirements.txt +RUN pip install -r requirements.txt # Copy FastAPI app COPY app /code/app @@ -53,4 +48,4 @@ COPY assets /code/assets COPY README.md /code/README.md EXPOSE 8080 -CMD /root/.pyenv/shims/uvicorn app.main:app --host 0.0.0.0 --port 8080 +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"] diff --git a/containers/fhir-converter/Makefile b/containers/fhir-converter/Makefile index af7c1f598..6380c3268 100644 --- a/containers/fhir-converter/Makefile +++ b/containers/fhir-converter/Makefile @@ -42,4 +42,8 @@ build-image: build-image-no-cache: @echo "Building Docker image for the FHIR Converter service without cache..." - docker compose build --no-cache + docker compose build --no-cache + +build-image-no-cache-service: + @echo "Building Docker image for the FHIR Converter service without cache..." + docker compose build --build-arg CACHEBUSTSERVICE=$(shell date +%s) diff --git a/containers/fhir-converter/README.md b/containers/fhir-converter/README.md index 29a43504d..67da97397 100644 --- a/containers/fhir-converter/README.md +++ b/containers/fhir-converter/README.md @@ -149,7 +149,7 @@ For local development, you may prefer to run the service directly from Python. T 4. Make a fresh virtual environment with `python -m venv .venv`. 5. Activate the virtual environment with `source .venv/bin/activate` (MacOS and Linux), `venv\Scripts\activate` (Windows Command Prompt), or `.venv\Scripts\Activate.ps1` (Windows PowerShell). 5. Install all of the Python dependencies for the ingestion service with `pip install -r requirements.txt` into your virtual environment. -6. Run the FHIR Converter on `localhost:8080` with `FHIR_CONVERTER_TOOl_PATH=~/fully/qualified/path/to/Microsoft.Health.Fhir.Liquid.Converter.Tool.dll python -m uvicorn app.main:app --host 0.0.0.0 --port 8080`. +6. Run the FHIR Converter on `localhost:8080` with `FHIR_CONVERTER_TOOl_PATH=~/fully/qualified/path/to/Microsoft.Health.Fhir.Liquid.Converter.Tool python -m uvicorn app.main:app --host 0.0.0.0 --port 8080`. ### Building the Docker Image diff --git a/containers/fhir-converter/app/service.py b/containers/fhir-converter/app/service.py index 98f1cc288..4ab16fef3 100644 --- a/containers/fhir-converter/app/service.py +++ b/containers/fhir-converter/app/service.py @@ -91,7 +91,7 @@ def convert_to_fhir( # Setup path variables converter_project_path = os.getenv( "FHIR_CONVERTER_TOOL_PATH", - "/build/FHIR-Converter/output/Microsoft.Health.Fhir.Liquid.Converter.Tool.dll", + "/build/FHIR-Converter/output/Microsoft.Health.Fhir.Liquid.Converter.Tool", ) if input_type == "vxu" or input_type == "elr": template_directory_path = "/build/FHIR-Converter/data/Templates/Hl7v2" @@ -110,7 +110,7 @@ def convert_to_fhir( # Formulate command for the FHIR Converter. fhir_conversion_command = [ - f"dotnet {converter_project_path} ", + f"{converter_project_path} ", "convert -- ", f"--TemplateDirectory {template_directory_path} ", f"--RootTemplate {root_template.value} ", @@ -127,6 +127,7 @@ def convert_to_fhir( capture_output=True, text=True, ) + # Print the standard output dev_mode = os.getenv("DEV_MODE", "false").lower() if dev_mode == "true":