From 1451ed705b53f67894708ef4e230c65b211fc7d2 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 20 Aug 2023 12:31:49 +0200 Subject: [PATCH] Add Dockerfile build --- Dockerfile | 48 +++++++++++++++++++++++++++++++++++++ docker/docker-entrypoint.sh | 5 ++++ 2 files changed, 53 insertions(+) create mode 100644 Dockerfile create mode 100644 docker/docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1222f9a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +ARG PYTHON_VERSION=3.11.0 +ARG POETRY_VERSION=1.5 + +FROM python:${PYTHON_VERSION} as staging + +ARG APP_NAME=verbanote +ARG APP_PATH=/verbanote +ARG PYTHON_VERSION +ARG POETRY_VERSION +ARG VERBANOTE_OUTPUT_PATH=/transcriptions + +ENV \ + PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONFAULTHANDLER=1 + +ENV \ + POETRY_VERSION=${POETRY_VERSION} \ + POETRY_HOME=/opt/poetry \ + POETRY_VIRTUALENVS_IN_PROJECT=true \ + POETRY_NO_INTERACTION=1 + +# installing poetry +RUN curl -sSL https://install.python-poetry.org | python3 - +ENV PATH="${POETRY_HOME}/bin:${PATH}" + +WORKDIR ${APP_PATH} +COPY ./poetry.lock ./pyproject.toml ./ +COPY ./${APP_NAME} ./${APP_NAME} + +# -------------- + +FROM staging as worker +ARG APP_NAME +ARG APP_PATH +ARG VERBANOTE_OUTPUT_PATH +ENV APP_NAME=${APP_NAME} +ENV APP_PATH=${APP_PATH} +ENV VERBANOTE_OUTPUT_PATH=${VERBANOTE_OUTPUT_PATH} + +WORKDIR ${APP_PATH} +RUN poetry install +RUN mkdir -p ${VERBANOTE_OUTPUT_PATH} + +COPY ./docker/docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh +ENTRYPOINT [ "/docker-entrypoint.sh" ] +CMD [ "python", "-u", "${APP_PATH}/{${APP_NAME}/rp_handler.py" ] diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh new file mode 100644 index 0000000..33319a0 --- /dev/null +++ b/docker/docker-entrypoint.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +# + +set -e +eval "exec $@"