|
1 | | -# Use an older, compatible Node.js image (v10) |
| 1 | +# Use the Node.js v10 image required for the old gitbook-cli |
2 | 2 | FROM node:10-alpine |
3 | 3 |
|
4 | 4 | # Set working directory |
5 | 5 | WORKDIR /app |
6 | 6 |
|
7 | | -# Alpine Linux is used, so we use 'apk' to install git |
| 7 | +# Install git |
8 | 8 | RUN apk add --no-cache git |
9 | 9 |
|
10 | | -# Install GitBook CLI globally |
| 10 | +# Install the GitBook command line tool |
11 | 11 | RUN npm install -g gitbook-cli |
12 | 12 |
|
13 | | -# Initialize GitBook by fetching a specific, stable version |
| 13 | +# Tell gitbook-cli to download the stable 3.2.3 engine |
14 | 14 | RUN gitbook fetch 3.2.3 |
15 | 15 |
|
16 | | -# Copy your documentation files to the container |
| 16 | +# Copy your local files (book.json, markdown, etc.) into the container |
17 | 17 | COPY . . |
18 | 18 |
|
19 | | -# Create a default book.json if one doesn't exist |
20 | | -RUN if [ ! -f "book.json" ]; then \ |
21 | | - echo '{"title": "My Documentation", "description": "Documentation served with GitBook"}' > book.json; \ |
22 | | - fi |
| 19 | +# --- THIS IS THE FIX FOR THE "NOT FOUND" ERROR --- |
| 20 | +# We are forcing the old npm client to use the public registry directly |
| 21 | +# and to ignore the SSL protocol errors that are likely causing the block. |
| 22 | +RUN npm config set registry https://registry.npmjs.org/ |
| 23 | +RUN npm config set "strict-ssl" false |
23 | 24 |
|
24 | | -# Install GitBook plugins (if any are specified in book.json) |
| 25 | +# Install the plugins listed in book.json using the now-fixed npm client |
25 | 26 | RUN gitbook install |
26 | 27 |
|
27 | | -# Build the static site |
| 28 | +# Build the static HTML site |
28 | 29 | RUN gitbook build |
29 | 30 |
|
30 | | -# Expose a port (using 4000 as a standard for gitbook serve) |
| 31 | +# Expose port 4000 for serving |
31 | 32 | EXPOSE 4000 |
32 | 33 |
|
33 | | -# Serve the built documentation on all network interfaces |
| 34 | +# The command to run when the container starts |
34 | 35 | CMD ["gitbook", "serve", "--port", "4000", "--host", "0.0.0.0"] |
0 commit comments