Skip to content

Commit

Permalink
feat: docker image support
Browse files Browse the repository at this point in the history
  • Loading branch information
atrifat committed Jul 19, 2024
1 parent 6b55cc3 commit 7bd9475
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM python:3.10-bookworm as builder

WORKDIR /builder

RUN addgroup --gid 1000 user
RUN adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user

ENV USER=user
ENV HOME=/home/user

RUN python3 -mvenv venv && ./venv/bin/pip install --no-cache-dir --upgrade pip

COPY requirements.txt requirements.txt

RUN ./venv/bin/pip install -U --no-cache-dir -r requirements.txt

FROM python:3.10-bookworm as runner

WORKDIR /app

RUN addgroup --gid 1000 user
RUN adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user

ENV USER=user
ENV HOME=/home/user

COPY --from=builder --chown=user:user /builder/venv /app/venv

COPY --chown=user:user app.py app.py

RUN chown -R user:user /app && chown -R user:user /home/user

USER user

ENV ENABLE_API_TOKEN=false
ENV API_TOKEN=
ENV APP_ENV=production
ENV LISTEN_HOST=0.0.0.0
ENV LISTEN_PORT=5000
ENV TOPIC_CLASSIFICATION_MODEL="cardiffnlp/twitter-roberta-base-dec2021-tweet-topic-multi-all"
ENV ENABLE_CACHE=false
ENV CACHE_DURATION_SECONDS=60
ENV TORCH_DEVICE=auto

EXPOSE $LISTEN_PORT

ENTRYPOINT [ "./venv/bin/python" , "app.py" ]

0 comments on commit 7bd9475

Please sign in to comment.