Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,26 @@ FROM node:20-alpine AS base
# Install dependencies only when needed
FROM base AS dev
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.

RUN apk add --no-cache libc6-compat
# libc6-compat & gcompat are needed for native modules (e.g. esbuild) on alpine.
# openssl is required for HTTPS requests (Octokit).
# git is required for husky, lint-staged, and metadata scripts.
RUN apk add --no-cache libc6-compat gcompat openssl git

WORKDIR /docs

ENV NODE_ENV=development
ENV NEXT_TELEMETRY_DISABLED=1

COPY . .
# Install dependencies separately to leverage Docker cache
COPY package.json package-lock.json ./
# Bypass postinstall since it requires source code which isn't copied yet
RUN npm pkg delete scripts.postinstall && npm install

RUN npm install
# Copy source code
COPY . .

CMD ["npm", "run", "dev"]
# Generate search-meta at runtime so it populates the mounted volume, then start dev
CMD ["sh", "-c", "npm run search-meta:gen && npm run dev"]

# Rebuild the source code only when needed
FROM dev AS builder
Expand All @@ -41,6 +48,7 @@ ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1

RUN set -xe; \
apk add --no-cache openssl; \
addgroup --system --gid 1001 nodejs; \
adduser --system --uid 1001 nextjs

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ It is deployed on the [Unikraft website](https://unikraft.org/)
It provides information for the latest version of [Unikraft](https://github.com/unikraft/unikraft) and [KraftKit](https://kraftkit.sh).

Documentation is written in [MDX](https://mdxjs.com/) format.
Building and deploying it requires Node and NPM.
Building and deploying it requires Node and npm.
You can build and run either natively or using Docker.

## Building and Testing Natively
Expand All @@ -29,7 +29,7 @@ For local development:
```console
docker build -t ghcr.io/unikraft/docs:dev --target dev .

docker run -it --rm -v $(pwd):/docs -w /docs -p 3000:3000 ghcr.io/unikraft/docs:dev
docker run -it --rm -v $(pwd):/docs -v unikraft_modules:/docs/node_modules -w /docs -p 3000:3000 ghcr.io/unikraft/docs:dev
```

For production deployment:
Expand Down
Loading