diff --git a/.dockerignore b/.dockerignore index 92260b89..a770c224 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ -venv +.git* +*venv* build diff --git a/Dockerfile b/Dockerfile index d73e2d12..0062c241 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,34 @@ +# Dockerfile for Readalong Studio Web API +# Build: `docker build --tag ras .` +# Run: `docker run -d -p 8000:8000 ras` for local testing, or use `-p` to map +# whichever host port you want to 8000 on the container. Set ORIGIN to the base +# URL of your Studio-Web for production deployments. + FROM alpine:latest AS runtime ENV APPHOME=/opt/readalong-studio # Lean, optimized installation of system dependencies -RUN apk add python3 py3-numpy py3-yaml git ffmpeg +RUN apk add python3 py3-yaml git ffmpeg FROM runtime AS build WORKDIR $APPHOME RUN apk add python3-dev py3-pip gcc g++ musl-dev ninja RUN python3 -m venv --system-site-packages $APPHOME/venv -RUN git clone https://github.com/roedoejet/g2p.git +RUN . $APPHOME/venv/bin/activate \ + && python3 -m pip install --upgrade pip COPY requirements*.txt $APPHOME/ RUN . $APPHOME/venv/bin/activate \ && python3 -m pip install -r $APPHOME/requirements.txt RUN . $APPHOME/venv/bin/activate \ && python3 -m pip install soundswallower -RUN cd $APPHOME/g2p \ - && . $APPHOME/venv/bin/activate python3 -m pip install -e . + +# requirements.txt already gets g2p@main from github, no need to clone it separately +# RUN git clone --depth=1 https://github.com/NRC-ILT/g2p.git +# RUN cd $APPHOME/g2p \ +# && . $APPHOME/venv/bin/activate \ +# && SETUPTOOLS_SCM_PRETEND_VERSION=$(cat .SETUPTOOLS_SCM_PRETEND_VERSION) python3 -m pip install -e . + # Do this after all the above so we don't needlessly rebuild COPY . $APPHOME/Studio RUN cd $APPHOME/Studio \ @@ -29,13 +41,7 @@ WORKDIR $APPHOME ENV VIRTUAL_ENV=$APPHOME/venv ENV PATH=$VIRTUAL_ENV/bin:$PATH -# Run this container with `docker run -d -p 8000:8000` for local -# testing, or use `-p` to map whichever host port you want to 8000 on -# the container. Set ORIGIN to the base URL of your Studio-Web for -# production deployments. - ENV PORT=8000 ENV ORIGIN=http://localhost:4200 EXPOSE $PORT -SHELL ["/bin/sh", "-c"] CMD gunicorn -w 4 -k uvicorn.workers.UvicornWorker readalongs.web_api:web_api_app --bind 0.0.0.0:$PORT diff --git a/pyproject.toml b/pyproject.toml index 1940f374..426d8316 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,7 @@ heroku = [ "readalongs[api]", # We don't actually use the panphon 0.22 improvements on heroku so stick to # 0.21 with its lighter weight dependencies - "panphon<0.22", + "ilt-panphon>=0.21.4,<0.22", ] ci = [ diff --git a/requirements.txt b/requirements.txt index e6d83e90..8649de2c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,7 +16,7 @@ # - soundswallower~=0.6.0 # - webvtt-py==0.5.1 # - gunicorn>=23.0.0; platform_system != "Windows" -# - panphon<0.22 +# - ilt-panphon<0.22,>=0.21.4 # - uvicorn>=0.30.1 # @@ -75,7 +75,7 @@ openpyxl==3.1.5 # via g2p packaging==25.0 # via gunicorn -ilt-panphon==0.21.3 +ilt-panphon==0.21.4 # via # hatch.envs.prod # g2p @@ -129,6 +129,3 @@ uvicorn==0.38.0 # via hatch.envs.prod webvtt-py==0.5.1 # via hatch.envs.prod - -# The following packages are considered to be unsafe in a requirements file: -# setuptools