Run yarn build during docker build (#1158)

This will alliviate the merge conflicts we keep getting by checking this
file into source control.


-----------

Now, when using docker-compose, to re-generate the `styles.css` file,
you can do so locally in the following ways:

1. locally run `yarn build`
2. run `docker compose build`
This commit is contained in:
Kenneth Reitz
2024-07-22 10:14:44 -04:00
committed by GitHub
parent 2176ea7abc
commit ad30efd71b
7 changed files with 60 additions and 29 deletions

View File

@@ -4,19 +4,34 @@ FROM python:3.11-slim AS builder-py
RUN apt update && apt install -y build-essential gcc python-dev-is-python3 libpq-dev postgresql-client ruby ruby-dev && rm -rf /var/lib/apt/lists/*
# Install Asciidoctor
# Install ruby's asciidoctor.
RUN gem install asciidoctor
RUN pip install -U uv
# Upgrade to the latest pip.
RUN pip install --upgrade pip
# Boostrap uv.
RUN pip install 'uv>=0.2.27,<0.3'
COPY ./requirements.txt ./code/requirements.txt
RUN python3 -m venv /venv
# Create the virtualenv.
RUN uv venv venv
# Activate the virtualenv and install the requirements.
RUN --mount=type=cache,target=/root/.cache \
. /venv/bin/activate && \
uv pip install -r /code/requirements.txt
# Builder step for JS.
FROM node:22-slim AS builder-js
COPY . /code/
WORKDIR /code/
RUN yarn build
# Final image.
FROM python:3.11-slim AS release
RUN apt update && apt install -y git libpq-dev ruby ruby-dev && rm -rf /var/lib/apt/lists/*
@@ -24,6 +39,9 @@ RUN apt update && apt install -y git libpq-dev ruby ruby-dev && rm -rf /var/lib/
# Install Asciidoctor
RUN gem install asciidoctor
# Boostrap uv.
RUN pip install'uv>=0.2.27,<0.3'
ENV PATH /venv/bin:/bin:/usr/bin:/usr/local/bin
ENV PYTHONDONTWRITEBYTECODE=true
ENV PYTHONPATH /code
@@ -34,6 +52,7 @@ RUN mkdir /code
COPY --from=builder-py /venv/ /venv/
COPY --from=builder-py /code/ /code/
COPY --from=builder-js /code/static/css/styles.css /code/static/css/styles.css
COPY . /code/
WORKDIR /code