From 5a64a7e115c0de982fd2540264fffca4784553bd Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Wed, 21 Jan 2026 11:47:05 +0000 Subject: [PATCH 1/2] build(medcat-trainer): Improve dockerfile layer caching --- medcat-trainer/webapp/Dockerfile | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/medcat-trainer/webapp/Dockerfile b/medcat-trainer/webapp/Dockerfile index a643948e2..6edb521ea 100644 --- a/medcat-trainer/webapp/Dockerfile +++ b/medcat-trainer/webapp/Dockerfile @@ -23,26 +23,32 @@ RUN apt install -y nodejs && apt install -y npm RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y ENV PATH="/root/.cargo/bin:${PATH}" -# Copy project -WORKDIR /home -COPY ./ . - -# copy backup crontab and chmod scripts -RUN chmod u+x /home/scripts/entry.sh && chmod u+x /home/scripts/crontab && cp /home/scripts/crontab /etc/crontab -RUN chmod u+x /home/scripts/nginx-entrypoint.sh - -# Build frontend +# Copy dependency files first for better layer caching WORKDIR /home/frontend +COPY frontend/package.json frontend/package-lock.json ./ RUN npm install && npm run build -# Install requirements for backend -WORKDIR /home/ +# Install Python dependencies +WORKDIR /home +COPY requirements.txt ./ RUN pip install pip --upgrade RUN pip install --upgrade setuptools RUN pip install --no-cache-dir -r requirements.txt + +# Download spaCy models (only requires spaCy, not application code) ARG SPACY_MODELS="en_core_web_md" RUN for SPACY_MODEL in ${SPACY_MODELS}; do python -m spacy download ${SPACY_MODEL}; done +# Copy rest of project +WORKDIR /home +COPY ./ . + +# copy backup crontab and chmod scripts +RUN chmod u+x /home/scripts/entry.sh && \ + chmod u+x /home/scripts/crontab && cp /home/scripts/crontab /etc/crontab && \ + chmod a+x /home/scripts/run.sh && \ + chmod a+x /home/scripts/run-bg-process.sh && \ + chmod u+x /home/scripts/nginx-entrypoint.sh + WORKDIR /home/api/ -RUN chmod a+x /home/scripts/run.sh -RUN chmod a+x /home/scripts/run-bg-process.sh + From 7becc22a226dd34a50a28ba120462cfd15163f09 Mon Sep 17 00:00:00 2001 From: alhendrickson <159636032+alhendrickson@users.noreply.github.com.> Date: Wed, 21 Jan 2026 12:06:20 +0000 Subject: [PATCH 2/2] build(medcat-trainer): Improve dockerfile layer caching - npm build --- medcat-trainer/webapp/Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/medcat-trainer/webapp/Dockerfile b/medcat-trainer/webapp/Dockerfile index 6edb521ea..dc252d70b 100644 --- a/medcat-trainer/webapp/Dockerfile +++ b/medcat-trainer/webapp/Dockerfile @@ -26,7 +26,7 @@ ENV PATH="/root/.cargo/bin:${PATH}" # Copy dependency files first for better layer caching WORKDIR /home/frontend COPY frontend/package.json frontend/package-lock.json ./ -RUN npm install && npm run build +RUN npm install # Install Python dependencies WORKDIR /home @@ -43,6 +43,10 @@ RUN for SPACY_MODEL in ${SPACY_MODELS}; do python -m spacy download ${SPACY_MODE WORKDIR /home COPY ./ . +# Build frontend +WORKDIR /home/frontend +RUN npm run build + # copy backup crontab and chmod scripts RUN chmod u+x /home/scripts/entry.sh && \ chmod u+x /home/scripts/crontab && cp /home/scripts/crontab /etc/crontab && \