Skip to content

Commit d1d349d

Browse files
authored
docs: dockerise dev (#9043)
Setting up Ruby v2.7 is getting increasingly difficult on newer systems. This PR aims to help with that by providing a simple way to launch a documentation dev environment.
1 parent 2b1e061 commit d1d349d

4 files changed

Lines changed: 45 additions & 0 deletions

File tree

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**
2+
3+
!/package.json
4+
!/bin/build-site.js
5+
!/bin/install-jekyll.sh
6+
!/package-lock.json
7+
!/docs/Gemfile
8+
!/docs/Gemfile.lock

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ Now you can build the site and start the dev server with:
118118

119119
You should now find the documentation at http://127.0.0.1:4000
120120

121+
You can also build and run the documentation with docker:
122+
123+
$ npm run dev-site-with-docker
124+
121125
Writing a PouchDB Blog Post
122126
--------------------------------------
123127

docs-dev.Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# maintain similarity to CI by using common base image:
2+
FROM ubuntu:20.04
3+
4+
RUN apt-get update && \
5+
apt-get --yes install \
6+
build-essential \
7+
curl \
8+
ruby-full \
9+
&& \
10+
apt-get clean && \
11+
rm -rf /var/lib/apt/lists/*
12+
13+
# TODO confirm ruby version is 2.7... if it matters
14+
RUN gem install bundler -v 2.1.4
15+
16+
ENV NODE_VERSION=22.12.0
17+
ENV NVM_DIR=/root/.nvm
18+
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
19+
RUN . "$NVM_DIR/nvm.sh" && nvm install 22
20+
ENV PATH="$NVM_DIR/versions/node/v${NODE_VERSION}/bin/:${PATH}"
21+
22+
WORKDIR /pouchdb-docs
23+
24+
COPY ./docs/ ./docs-bundler
25+
RUN cd docs-bundler && bundle install
26+
27+
COPY package.json package-lock.json .
28+
RUN npm install --ci
29+
30+
COPY ./bin/ ./bin/
31+
32+
CMD ["npm", "run", "build-site"]

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"install-jekyll": "./bin/install-jekyll.sh",
2424
"publish-site": "./bin/publish-site.sh",
2525
"build-site": "node ./bin/build-site.js",
26+
"dev-site-with-docker": "docker build --file docs-dev.Dockerfile --progress=plain . && docker run -it --rm --volume $PWD/docs:/pouchdb-docs/docs -p 4000:4000 $(docker build --quiet .)",
2627
"test-coverage": "./bin/test-coverage.sh",
2728
"coverage": "COVERAGE=1 SERVER=pouchdb-server POUCHDB_SERVER_FLAGS=--in-memory PLUGINS=pouchdb-find ./bin/test-coverage.sh",
2829
"build-test": "npm run build-test-utils && npm run build-perf",

0 commit comments

Comments
 (0)