diff --git a/README.md b/README.md index 0f94bef1..16f2a597 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,12 @@ BMDS UI is a user interface for running [pybmds](https://pypi.org/project/pybmds * It can deployed as a web application, such as [BMDS Online](https://bmdsonline.epa.gov) * It can be deployed locally as a desktop application, which we call **BMDS Desktop**. - **BMDS Desktop application home screen:** ![](./docs/img/bmds-desktop.jpg) **An example of the the user interface for model results:** ![](./docs/img/bmds-output.jpg) - ## BMDS Online vs. BMDS Desktop BMDS Desktop is designed to run locally on your desktop computer in fully offline mode; it does not interact with any resources on the internet after initial installation. BMDS Online can be deployed online publicly or internally at a company or organization. Key differences between the software are described below: @@ -29,3 +27,12 @@ Database technology|Uses a sqlite database file (single file)|Uses a PostgreSQL The BMDS Desktop has a startup screen where you can select which database file you'd like to use in your application. You can have multiple databases on your computer, one per project for example: ![](./docs/img/desktop-startup.jpg) + +## Build Notes + +To build containers for deployment: + +```bash +make build +docker compose -f compose/build.yml --project-directory . build +``` diff --git a/compose/app/Dockerfile b/compose/app/Dockerfile index 13faa994..985a0f54 100644 --- a/compose/app/Dockerfile +++ b/compose/app/Dockerfile @@ -1,48 +1,39 @@ -FROM python:3.11-slim-bullseye +FROM quay.io/centos/centos:stream9-minimal -ENV BMDS_UI_VERSION=24.1a4 -ENV BMDS_VERSION=24.1a4 -ENV EXTRA_BMDS_BUILD_ARGS= +ENV PYTHON_VERSION=3.12 \ + PYTHONBUFFERED=1 \ + PYTHONIOENCODING=UTF-8 \ + PYTHONFAULTHANDLER=1 \ + PIP_NO_CACHE=off \ + LANG=C.UTF-8 RUN groupadd -g 555 -r app && \ - useradd -u 555 -r -g app app - -# dependencies wait-for: netcat -# dependencies bmds: libgslcblas0 libgsl-dev -RUN apt-get update -y && \ - apt-get install -y netcat libgslcblas0 libgsl-dev + useradd -u 555 -r -g app app && \ + \ + INSTALL_PKGS="python${PYTHON_VERSION} nc" && \ + VERIFY_PKGS="python${PYTHON_VERSION}" && \ + microdnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \ + rpm -V $VERIFY_PKGS && \ + microdnf -y clean all --enablerepo='*' && \ + ln -s /usr/bin/"python${PYTHON_VERSION}" /usr/local/bin/python COPY ./compose/app/wait-for.sh /app/bin/wait-for.sh COPY ./compose/app/sync.sh /app/bin/sync.sh COPY ./compose/app/web.sh /app/bin/web.sh COPY ./compose/app/workers.sh /app/bin/workers.sh COPY ./compose/app/cron.sh /app/bin/cron.sh -COPY ./compose/app/test.py /app/test.py - -# used in some dev/staging environments COPY ./tests/data/db.yaml /app/test-db-fixture.yaml - -# 1) install start-scripts -# 2) install fonts -# 3) create logs path -RUN mkdir -p /app/logs && \ - mkdir -p /app/public/media - COPY ./dist /dist -RUN pip install -U pip && \ - pip install "${EXTRA_BMDS_BUILD_ARGS} pybmds==${BMDS_VERSION}" --no-cache-dir && \ - pip install "dist/bmds_ui-${BMDS_UI_VERSION}-py3-none-any.whl[pg,prod]" --no-cache-dir && \ +RUN python -m ensurepip --upgrade && \ + python -m pip install -U pip && \ + \ + for file in dist/bmds_ui-*.whl; do python -m pip install "$file[pg,prod]" --no-cache-dir ; done && \ \ rm -rf /dist && \ - pip uninstall -y pip + python -m pip uninstall -y pip && \ + \ + chown -R app:app /app WORKDIR /app - -RUN chown -R app:app /app USER app - -ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH - -RUN ldd /usr/local/lib/python3.11/site-packages/pybmds/bmdscore.cpython-*-x86_64-linux-gnu.so && \ - python /app/test.py diff --git a/compose/app/test.py b/compose/app/test.py deleted file mode 100644 index ddfe49c8..00000000 --- a/compose/app/test.py +++ /dev/null @@ -1,9 +0,0 @@ -import pybmds -from pybmds.models.dichotomous import Logistic - -dataset = pybmds.DichotomousDataset( - doses=[0, 50, 100, 150, 200], ns=[100, 100, 100, 100, 100], incidences=[0, 5, 30, 65, 90] -) -model = Logistic(dataset=dataset) -result = model.execute() -print(result.model_dump()) # noqa: T201 diff --git a/compose/build.yml b/compose/build.yml new file mode 100644 index 00000000..13c71d48 --- /dev/null +++ b/compose/build.yml @@ -0,0 +1,25 @@ +version: '3' + +services: + + postgres: + build: ./compose/postgres + platform: linux/x86_64 + ports: + - "0.0.0.0:5432:5432" + + redis: + build: ./compose/redis + platform: linux/x86_64 + ports: + - "0.0.0.0:6379:6379" + + app: + build: + context: . + dockerfile: ./compose/app/Dockerfile + platform: linux/x86_64 + + nginx: + build: ./compose/nginx + platform: linux/x86_64