mirror of
https://github.com/readthedocs/sphinx_rtd_theme.git
synced 2025-02-25 18:55:21 -06:00
Wrapping up the Docker work, using docker cp again in order to copy assets out of containers
This commit is contained in:
parent
4393bd2039
commit
ba059c7970
2
.gitignore
vendored
2
.gitignore
vendored
@ -27,3 +27,5 @@ sphinx_rtd_theme/static/js/html5shiv.min.js
|
||||
sphinx_rtd_theme/static/js/html5shiv-printshiv.min.js
|
||||
.direnv/
|
||||
.envrc
|
||||
# Used for dockerized builds
|
||||
.container_id
|
||||
|
19
Dockerfile
19
Dockerfile
@ -8,23 +8,25 @@ RUN apk add npm make py3-pip py3-wheel
|
||||
|
||||
# Add an extra verification that we have the right node
|
||||
# because the above caused issues
|
||||
RUN python3 --version
|
||||
RUN node -v && node -v | grep -q v14 &&\
|
||||
python3 --version && python3 --version | grep -q "3.10"
|
||||
|
||||
RUN pip install pip --upgrade
|
||||
|
||||
RUN mkdir -p /project/src/ &&\
|
||||
mkdir -p /project/docs/ &&\
|
||||
mkdir -p /project/docs/build/ &&\
|
||||
mkdir -p /project-minimal-copy/sphinx_rtd_theme &&\
|
||||
touch /project-minimal-copy/sphinx_rtd_theme/__init__.py
|
||||
|
||||
# This is the main working directory where node_modules
|
||||
# gets built. During runtime, it's mixed with directories
|
||||
# from an external environment through a bind mount
|
||||
WORKDIR /project
|
||||
|
||||
# Copy files necessary to run "npm install" and save
|
||||
# installed packages in the docker image (makes the runtime
|
||||
# so much faster)
|
||||
COPY package.json /project/
|
||||
|
||||
# COPY package-lock.json /project/
|
||||
|
||||
COPY bin/preinstall.js /project/bin/preinstall.js
|
||||
|
||||
RUN cd /project
|
||||
@ -37,16 +39,19 @@ RUN npm install --package-lock-only &&\
|
||||
|
||||
# This is strictly speaking not necessary, just makes
|
||||
# running the container faster...
|
||||
# Install dependencies, then uninstall project itsel
|
||||
# Install dependencies, then uninstall project itself
|
||||
COPY setup.py README.rst /project-minimal-copy/
|
||||
RUN cd /project-minimal-copy &&\
|
||||
pip install ".[dev]" &&\
|
||||
/usr/bin/yes | pip uninstall sphinx_rtd_theme
|
||||
|
||||
|
||||
# Copy in stuff we need to run the project
|
||||
# Copy in files that we need to run the project. These files
|
||||
# will not be mounted into the runtime from external environment
|
||||
# so we copy them during build.
|
||||
COPY webpack.common.js webpack.dev.js webpack.prod.js /project/
|
||||
|
||||
# Copy in the entrypoint and we're done
|
||||
COPY docker-entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
|
18
Makefile
Normal file
18
Makefile
Normal file
@ -0,0 +1,18 @@
|
||||
SHELL := /bin/bash
|
||||
CWD := $(shell cd -P -- '$(shell dirname -- "$0")' && pwd -P)
|
||||
|
||||
docker-images:
|
||||
docker-compose build
|
||||
|
||||
docker-npm-build:
|
||||
rm -f .container_id
|
||||
docker-compose run -d sphinx_rtd_theme build > .container_id
|
||||
docker container wait "$(shell cat .container_id)"
|
||||
docker cp "$(shell cat .container_id):/project/sphinx_rtd_theme" .
|
||||
docker cp "$(shell cat .container_id):/project/package-lock.json" .
|
||||
@echo "Done building"
|
||||
|
||||
docker-npm-dev:
|
||||
docker-compose run sphinx_rtd_theme dev
|
||||
|
||||
docker-build-all: docker-images docker-npm-build
|
@ -6,7 +6,21 @@ services:
|
||||
volumes:
|
||||
- type: "bind"
|
||||
source: "./"
|
||||
target: "/project-working-copy"
|
||||
target: "/project-readonly"
|
||||
read_only: true
|
||||
- type: "volume"
|
||||
target: "/project-readonly/sphinx_rtd_theme.egg-info"
|
||||
- type: "bind"
|
||||
source: "./src"
|
||||
target: "/project/src"
|
||||
read_only: true
|
||||
- type: "bind"
|
||||
source: "./docs"
|
||||
target: "/project/docs"
|
||||
read_only: false #todo: fix this
|
||||
- type: "volume"
|
||||
target: "/project/docs/_build"
|
||||
|
||||
network_mode: host
|
||||
ports:
|
||||
- "1919:1919"
|
||||
|
@ -1,17 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Install the readonly project in editable mode and make sure
|
||||
# all dependencies are upgrade. This is mounted in from the
|
||||
# outside, but it is on purpose that it is readonly!
|
||||
cp -r /project/node_modules /project-working-copy/
|
||||
cd /project-working-copy
|
||||
# Update latest Python dependencies in case they have changed
|
||||
cd /project-readonly
|
||||
pip install --upgrade -e ".[dev]"
|
||||
|
||||
# This helps a potential permission issue, but might be removed
|
||||
# pending some more investigation of docker host file system
|
||||
# permissions in the bind mount
|
||||
npm cache clean --force
|
||||
npm install
|
||||
# npm cache clean --force
|
||||
# npm install
|
||||
|
||||
cd /project
|
||||
cp -r /project-readonly/sphinx_rtd_theme .
|
||||
|
||||
echo "Going to invoke: npm run $@"
|
||||
npm run $@
|
||||
|
@ -84,12 +84,14 @@ Use the following steps:
|
||||
# Builds an updated version of the docker image
|
||||
$ docker-compose build
|
||||
|
||||
# Runs the docker environment and builds the assets. The container exits after completing the build.
|
||||
$ docker-compose run sphinx_rtd_theme build
|
||||
|
||||
# Runs the development webserver
|
||||
$ docker-compose run sphinx_rtd_theme dev
|
||||
|
||||
|
||||
# If you want to copy stuff out of the Docker environment, run this make
|
||||
# target or read the actual Makefile to see what is going on.
|
||||
# We suggest running this command every time that you want to quickly build
|
||||
# new CSS/JS assets
|
||||
$ make docker-build-all
|
||||
|
||||
Every time you change the Node or Python requirements, you will need to rebuild images with ``docker-compose run sphinx_rtd_theme build``. If you change SASS or JS, you will need to rebuild assets.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user