lion-devs / otomati-app

Otomati APP help communicate with AI models in a more human-like way.
Apache License 2.0
1 stars 1 forks source link

[FEAT]: add Dockerfile support #5

Closed JustinHung0407 closed 2 weeks ago

JustinHung0407 commented 2 weeks ago

Description

Summary

I would like to request the addition of a Dockerfile to this project. Having a Dockerfile would allow the project to be easily containerized, making it simpler to deploy and ensuring consistency across different environments.

Benefits

Proposed Dockerfile

Here is a proposed Dockerfile based on the current structure of the project:


FROM python:3.12.4-slim-bookworm as py-build

ARG POETRY_VERSION=1.8.3

WORKDIR /app

# Use set -eux to ensure detailed output and error handling
RUN set -eux; \
    apt-get update; \
    apt-get install -y curl

COPY pyproject.toml poetry.lock /app/
COPY otomati_app /app/otomati_app
RUN touch README.md && touch LICENSE

ENV POETRY_NO_INTERACTION=1 \
    POETRY_VIRTUALENVS_IN_PROJECT=1 \
    POETRY_VIRTUALENVS_CREATE=1 \
    POETRY_CACHE_DIR=/tmp/poetry_cache \
    VIRTUAL_ENV=/app/.venv

ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN pip install poetry==${POETRY_VERSION}

RUN poetry check
# Use -vv to show detailed steps of poetry install
RUN poetry install -vv --no-root --no-dev

FROM python:3.12.4-slim-bookworm

ENV PORT=8009

COPY --from=py-build /app /app
WORKDIR /app

EXPOSE $PORT
EXPOSE 8181

HEALTHCHECK CMD curl --fail http://localhost:$PORT/healthz || exit 1

# Set PYTHONPATH to ensure Python can find otomati_app module
ENV PYTHONPATH=/app

# Use sh -c to indirectly execute command containing environment variable
ENTRYPOINT ["sh", "-c", "streamlit run otomati_app/Home.py --server.port=${PORT:-8009} --server.address=0.0.0.0"]

### Additional Information

_No response_