Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

[WIP] Initial setup for running the website in Docker #286

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ sudo sysctl -w kern.maxfiles=100000
sudo sysctl -w kern.maxfilesperproc=65535
```

## Docker

[Docker Setup Guide](./docker/README.md)

# How it is deployed

While the above describes how the content is built locally, https://knative.dev/ is built and served by [Netlify](https://netlify.com/) on their platform.
Expand Down
18 changes: 18 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:18.04

RUN apt-get update -y && apt-get install git wget -y

RUN wget https://github.com/gohugoio/hugo/releases/download/v0.81.0/hugo_extended_0.81.0_Linux-64bit.deb
RUN dpkg -i hugo_extended_0.81.0_Linux-64bit.deb

RUN git clone --recurse-submodules https://github.com/knative/website.git
RUN git clone https://github.com/knative/docs.git

WORKDIR /website

COPY scripts.patch .
RUN patch -p0 < scripts.patch

ENTRYPOINT ["/bin/bash", "scripts/localbuild.sh","-s","reload"]

EXPOSE 1313
39 changes: 39 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# knative-docs-docker

```bash
git clone [email protected]:knative/website.git
```

```bash
cd website/docker
```

```bash
docker build -t {USER/knative-docs} .
```

There are custom scripts that avoid deletion of this folder in processsourcefiles. If using the default version of the script (not in the Dockerfile image build) then it will delete the directory. **Test this out using a test directory you have cloned and change GOPATH to the test directory. (/home/user/testing/docs/docs)**

Just Docs
```bash
docker run --name=knative-docs -d -v $GOPATH/src/github.com/knative.dev/docs/docs:/website/content/en/docs -p 9001:1313 USER/knative-docs:latest
```

Docs and Blog
```bash
docker run --name=knative-docs -d -v $GOPATH/src/github.com/knative.dev/docs/docs:/website/content/en/docs -v $GOPATH/src/github.com/knative.dev/docs/blog:/website/content/en/blog -p 9001:1313 USER/knative-docs:latest
```

This will run the service on port 9001, but you can pick any port you want. The container is listening on 1313.

If you want to run an already built image you can specify mpetason/knative-docs:latest instead of building locally.

Just Docs
```bash
docker run --name=knative-docs -d -v $GOPATH/src/github.com/knative.dev/docs/docs:/website/content/en/docs -p 9001:1313 mpetason/knative-docs:latest
```

Docs and Blog
```bash
docker run --name=knative-docs -d -v $GOPATH/src/github.com/knative.dev/docs/docs:/website/content/en/docs -v $GOPATH/src/github.com/knative.dev/docs/blog:/website/content/en/blog -p 9001:1313 mpetason/knative-docs:latest
```
67 changes: 67 additions & 0 deletions docker/scripts.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
--- scripts/localbuild.sh 2021-03-22 14:07:32.533556409 -0700
+++ docker/localbuild.sh 2021-04-12 20:56:04.615203305 -0700
@@ -150,11 +150,11 @@
;;
s)
echo 'Running Hugo server'
- SERVER="server $LIVERELOAD"
- if [ "${OPTARG}" = "reload" ]; then
- echo 'with live reload'
- LIVERELOAD=" --disableFastRender --renderToDisk"
- fi
+ SERVER="server "
+ # if [ "${OPTARG}" = "reload" ]; then
+ # echo 'with live reload'
+ # LIVERELOAD=" --disableFastRender --renderToDisk"
+ # fi
;;
esac
done
@@ -167,7 +167,7 @@

# BUILD MARKDOWN
# Start HUGO build
-hugo $SERVER --baseURL "" --environment "$BUILDENVIRONMENT" --gc
+exec hugo $SERVER --disableFastRender --baseURL "" --environment "$BUILDENVIRONMENT" --bind=0.0.0.0 --gc

if [ -z "$SERVER" ]; then
echo ''
@@ -175,3 +175,4 @@
echo ''
echo 'Static HTML files output to public/. Open public/index.html to view these files.'
fi
+
--- scripts/processsourcefiles.sh 2021-04-07 11:05:32.746104145 -0700
+++ docker/processsourcefiles.sh 2021-04-12 20:56:07.385965069 -0700
@@ -8,7 +8,7 @@
# A temp directory is used and move files around and prevent git clone errors (fails if directory exists).

# Clean slate: Make sure that nothing from a past build exists in the /content/ or /temp/ folders
-rm -rf content/en
+# rm -rf content/en
rm -rf temp

if [ "$BUILDALLRELEASES" = "true" ]
@@ -27,7 +27,7 @@
git clone --quiet -b main https://github.com/"$FORK".git content/en
echo 'Getting pre-release development docs from main branch'
# Move "pre-release" docs content into the 'development' folder:
- mv content/en/docs content/en/development
+ # mv content/en/docs content/en/development
# DOCS BRANCHES
echo '------ Cloning all docs releases ------'
# Get versions of released docs from their branches in "$FORK"
@@ -67,7 +67,7 @@
echo '------ BUILDING YOUR LOCAL KNATIVE/DOCS CLONE ------'
echo 'Copying local clone of knative/docs into the /docs folder under:'
pwd
- cp -r ../docs content/en/
+ #cp -r ../docs content/en/
if [ -d "../community" ]; then
echo 'Also copying the local clone of knative/community into the /community/contributing folder.'
cp -r ../community/* content/en/community/contributing
@@ -184,3 +184,4 @@
# GET HANDCRAFTED SITE LANDING PAGE
echo 'Copying the override files into the /content/ folder'
cp -rfv content-override/* content/
+