Skip to content

Commit

Permalink
switch to centos and update to python3.12 (#61)
Browse files Browse the repository at this point in the history
* swtich to centos and update to python3.12

* add build notes and compose file for building

* commit content added for testing (remove in next commit)

* Revert "commit content added for testing (remove in next commit)"

This reverts commit a30febb.

* cleanup
  • Loading branch information
shapiromatron authored Aug 22, 2024
1 parent 6b3734d commit 0f0b287
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 42 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
```
53 changes: 22 additions & 31 deletions compose/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
9 changes: 0 additions & 9 deletions compose/app/test.py

This file was deleted.

25 changes: 25 additions & 0 deletions compose/build.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0f0b287

Please sign in to comment.