Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster doc preview #1773

Merged
merged 5 commits into from
Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ docs/firebase-debug*
docs/public
docs/resources
docs/node_modules
docs/themes
docs/package-lock.json
pkg/skaffold/color/debug.test
5 changes: 0 additions & 5 deletions .gitmodules

This file was deleted.

25 changes: 4 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ BUILD_PACKAGE = $(REPOPATH)/cmd/skaffold

VERSION_PACKAGE = $(REPOPATH)/pkg/skaffold/version
COMMIT = $(shell git rev-parse HEAD)
BASE_URL ?= https://skaffold.dev
VERSION ?= $(shell git describe --always --tags --dirty)

GO_GCFLAGS := "all=-trimpath=${PWD}"
Expand Down Expand Up @@ -179,29 +178,13 @@ submit-release-trigger:

#utilities for skaffold site - not used anywhere else

.PHONY: docs-controller-image
docs-controller-image:
docker build -t gcr.io/$(GCP_PROJECT)/docs-controller -f deploy/webhook/Dockerfile .


.PHONY: preview-docs
preview-docs: start-docs-preview clean-docs-preview

.PHONY: docs-preview-image
docs-preview-image:
docker build -t skaffold-docs-previewer -f deploy/webhook/Dockerfile --target runtime_deps .

.PHONY: start-docs-preview
start-docs-preview: docs-preview-image
docker run --rm -ti -v $(PWD):/app --workdir /app/ -p 1313:1313 skaffold-docs-previewer bash -xc deploy/docs/preview.sh
preview-docs:
./deploy/docs/local-preview.sh hugo serve -D --bind=0.0.0.0

.PHONY: build-docs-preview
build-docs-preview: docs-preview-image
docker run --rm -ti -v $(PWD):/app --workdir /app/ -p 1313:1313 skaffold-docs-previewer bash -xc deploy/docs/build.sh

.PHONY: clean-docs-preview
clean-docs-preview: docs-preview-image
docker run --rm -ti -v $(PWD):/app --workdir /app/ -p 1313:1313 skaffold-docs-previewer bash -xc deploy/docs/clean.sh
build-docs-preview:
./deploy/docs/local-preview.sh hugo --baseURL=https://skaffold.dev

# schema generation

Expand Down
21 changes: 6 additions & 15 deletions deploy/docs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -exu

## This script builds the Skaffold site assuming it's ran from a
## cloned Skaffold repo with no submodules initialized. The script initializes the git submodules for
## the site's theme in a standard manner, thus this script can be used locally as well as for the PR review flow.
set -x
readonly BASE_URL=${1}

readonly DOCSY_COMMIT=$(git config -f .gitmodules submodule.docsy.commit)
readonly REPO_DIR=$(pwd)
readonly BASE_URL=${1:-"http://localhost:1313"}

git submodule init && \
git submodule update --init && \
cd docs/themes/docsy && \
git checkout ${DOCSY_COMMIT} && \
git submodule update --init --recursive && \
cd ${REPO_DIR}/docs && \
npm i -D autoprefixer && \
cd docs
mkdir -p themes
ln -s /app/docs/themes/docsy ./themes/docsy
ln -s /app/docs/node_modules ./node_modules
hugo --baseURL=${BASE_URL}
6 changes: 3 additions & 3 deletions deploy/docs/cloudbuild-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ steps:
- 'gcr.io/$PROJECT_ID/docs-controller:latest'
- '--cache-from'
- 'gcr.io/$PROJECT_ID/docs-controller:latest'
- '-f'
- 'deploy/webhook/Dockerfile'
- '.'
- '--target'
- 'runtime_deps'
- 'deploy/webhook'

- name: gcr.io/$PROJECT_ID/docs-controller:latest
env:
Expand Down
6 changes: 3 additions & 3 deletions deploy/docs/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ steps:
- 'gcr.io/$PROJECT_ID/docs-controller:latest'
- '--cache-from'
- 'gcr.io/$PROJECT_ID/docs-controller:latest'
- '-f'
- 'deploy/webhook/Dockerfile'
- '.'
- '--target'
- 'runtime_deps'
- 'deploy/webhook'

- name: gcr.io/$PROJECT_ID/docs-controller:latest
env:
Expand Down
18 changes: 11 additions & 7 deletions deploy/docs/clean.sh → deploy/docs/local-preview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

readonly REPO_DIR=$(pwd)
set -e

pushd ${REPO_DIR}/docs
readonly CURRENT_DIR=$(pwd)
readonly DOCS_DIR="${CURRENT_DIR}/docs"

rm -rf public resources node_modules package-lock.json && \
git submodule deinit -f . && \
rm -rf themes/docsy/* && \
rm -rf ${REPO_DIR}/.git/modules/docsy
MOUNTS="-v ${CURRENT_DIR}/.git:/app/.git:ro"
MOUNTS="${MOUNTS} -v ${DOCS_DIR}/config.toml:/app/docs/config.toml:ro"

popd
for dir in $(find ${DOCS_DIR} -type dir -mindepth 1 -maxdepth 1 | grep -v themes | grep -v public | grep -v resources | grep -v node_modules); do
MOUNTS="${MOUNTS} -v $dir:/app/docs/$(basename $dir):ro"
done

docker build -t skaffold-docs-previewer --target runtime_deps deploy/webhook
docker run --rm -ti -p 1313:1313 ${MOUNTS} skaffold-docs-previewer $@
16 changes: 6 additions & 10 deletions deploy/docs/preview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

## This script starts a preview of the Skaffold site assuming it's ran from a
## cloned Skaffold repo with no submodules initialized. The script initializes the git submodules for
## the site's theme in a standard manner, thus this script can be used locally as well as for the PR review flow.
set -x
set -exu

readonly REPO_DIR=$(pwd)
readonly BASE_URL=${1:-"http://localhost:1313"}

bash ${REPO_DIR}/deploy/docs/build.sh ${BASE_URL}

cd ${REPO_DIR}/docs
readonly BASE_URL=${1}

cd docs
mkdir -p themes
ln -s /app/docs/themes/docsy ./themes/docsy
ln -s /app/docs/node_modules ./node_modules
hugo serve --bind=0.0.0.0 -D --baseURL=${BASE_URL}
8 changes: 8 additions & 0 deletions deploy/webhook/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
# required for releasing the docs
firebase-tools

WORKDIR /app/docs/themes/docsy
RUN git clone https://github.com/google/docsy.git . \
&& git reset --hard a7141a2eac26cb598b707cab87d224f9105c315d \
&& git submodule update --init --recursive

WORKDIR /app/docs
RUN npm i -D autoprefixer

FROM golang:1.10 as webhook
WORKDIR $GOPATH/src/github.com/GoogleContainerTools/skaffold
COPY . .
Expand Down
1 change: 0 additions & 1 deletion docs/themes/docsy
Submodule docsy deleted from a7141a