Skip to content

Commit

Permalink
Simplify docs/Dockerfile and install dependencies inside (web-platfor…
Browse files Browse the repository at this point in the history
foolip authored Mar 18, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent ab76735 commit db05cf5
Showing 2 changed files with 14 additions and 26 deletions.
34 changes: 11 additions & 23 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -6,31 +6,19 @@ ENV DEBIAN_FRONTEND=noninteractive \

# General requirements not in the base image
RUN apt-get -qqy update \
&& apt-get -qqy install \
ca-certificates \
curl \
git \
npm \
python3 \
python3-distutils \
python3-pip \
python3.9 \
python3-distutils \
python3.9-venv \
software-properties-common \
tzdata \
sudo \
unzip \
# Set Python 3.9 as the default
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2;

# Make sure we're using the latest pip
RUN pip install --upgrade pip \
&& pip install virtualenv
&& apt-get -qqy install git npm python3.9 python3.9-venv

WORKDIR /app/

COPY ./package.json ./
COPY package.json requirements.txt ./

RUN npm install .
ENV PATH=/app/node_modules/.bin:$PATH

# Use venv to create a virtual environment with the docs dependencies installed,
# setting the environment variables needed for this to always be active. The
# `./wpt build-docs` then uses this venv with --skip-venv-setup.
ENV VIRTUAL_ENV=/app/venv
RUN python3.9 -m venv $VIRTUAL_ENV
ENV PATH=$VIRTUAL_ENV/bin:$PATH
RUN pip install -r requirements.txt
6 changes: 3 additions & 3 deletions docs/frontend.py
Original file line number Diff line number Diff line change
@@ -84,8 +84,9 @@ def docker_run(**kwargs):
if os.isatty(os.isatty(sys.stdout.fileno())):
cmd.append("-it")
cmd.extend(["wpt:docs", "./wpt"])
if kwargs["venv"]:
cmd.extend(["--venv", kwargs["venv"]])
# /app/venv is created during docker build and is always active inside the
# container.
cmd.extend(["--venv", "/app/venv", "--skip-venv-setup"])
cmd.extend(["build-docs", "--type", kwargs["type"]])
if kwargs["serve"] is not None:
cmd.extend(["--serve", str(kwargs["serve"])])
@@ -96,7 +97,6 @@ def docker_run(**kwargs):
def build(_venv, **kwargs):
if kwargs["docker"]:
docker_build()
kwargs["venv"] = "/app/venv"
return docker_run(**kwargs)

out_dir = os.path.join(here, "_build")

0 comments on commit db05cf5

Please sign in to comment.