Option to not use docker for Makefile in docs/website (#1087)
## Description This makes it so that we have an option to locally run all Makefile targets without having to go through Docker. That said, it retains Docker as the default way to run it, but now we can set an evn variable `CORSO_USE_DOCKER=-1` to skip running through docker. I understand if this looks a bit hacky and don't want to add it in, but thought I wold propose this anyways. While not major, I was able to get a good amount of decrease in build times. ## Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [x] 💻 CI/Deployment - [ ] 🐹 Trivial/Minor ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> ## Test Plan <!-- How will this be tested prior to merging.--> - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
29015df8ef
commit
4b94c4f012
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -93,6 +93,8 @@ jobs:
|
|||||||
npm i -g markdownlint-cli@0.32.2 # NOTE: update in Dockerfile when updating
|
npm i -g markdownlint-cli@0.32.2 # NOTE: update in Dockerfile when updating
|
||||||
|
|
||||||
- name: Run docs lint
|
- name: Run docs lint
|
||||||
|
env:
|
||||||
|
CORSO_USE_DOCKER: -1 # prevent using docker inside makefile
|
||||||
run: |
|
run: |
|
||||||
cd docs && make -o genclidocs check
|
cd docs && make -o genclidocs check
|
||||||
|
|
||||||
|
|||||||
@ -1,69 +1,60 @@
|
|||||||
.PHONY: buildimage build dev shell check genclidocs
|
.PHONY: buildimage build dev shell check genclidocs _validatemdgen
|
||||||
|
|
||||||
|
# Specify `CORSO_USE_DOCKER=-1` to skip using Docker for builds
|
||||||
CORSO_BUILD_DIR := /tmp/.corsobuild
|
CORSO_BUILD_DIR := /tmp/.corsobuild
|
||||||
CORSO_BUILD_CACHE := ${CORSO_BUILD_DIR}/cache
|
CORSO_BUILD_CACHE := ${CORSO_BUILD_DIR}/cache
|
||||||
CORSO_BUILD_MOD := ${CORSO_BUILD_DIR}/mod
|
CORSO_BUILD_MOD := ${CORSO_BUILD_DIR}/mod
|
||||||
CORSO_BUILD_BIN := ${CORSO_BUILD_DIR}/bin
|
CORSO_BUILD_BIN := ${CORSO_BUILD_DIR}/bin
|
||||||
|
CORSO_REPO := /go/src/github.com/alcionai/corso
|
||||||
|
CORSO_LOCAL_PATH := $(shell git rev-parse --show-toplevel)
|
||||||
|
DOCSC := docker run --rm -it -p 3000:3000 -v ${PWD}:/usr/src/docs alcion/docs
|
||||||
|
DOCSE := ${DOCSC} # for enforcing docker container as environment
|
||||||
|
GOC := docker run --rm -it \
|
||||||
|
-v ${CORSO_LOCAL_PATH}:${CORSO_REPO} -v ${CORSO_BUILD_DIR}:${CORSO_BUILD_DIR} \
|
||||||
|
--env GOCACHE=${CORSO_BUILD_CACHE} --env GOMODCACHE=${CORSO_BUILD_MOD} --env GOTMPDIR=${CORSO_BUILD_DIR} \
|
||||||
|
--workdir ${CORSO_REPO}/src \
|
||||||
|
golang:1.18
|
||||||
|
ifeq (${CORSO_USE_DOCKER},-1)
|
||||||
|
DOCSC :=
|
||||||
|
GOC := cd ${CORSO_LOCAL_PATH}/src &&
|
||||||
|
CORSO_REPO := ${CORSO_LOCAL_PATH}
|
||||||
|
endif
|
||||||
|
|
||||||
CORSO_REPO := ${PWD}/..
|
MDGEN_SRC := ${CORSO_REPO}/src/cmd/mdgen/mdgen.go
|
||||||
CORSO_REPO_CONTAINER := /go/src/github.com/alcionai/corso
|
|
||||||
|
|
||||||
MDGEN_SRC_CONTAINER := ${CORSO_REPO_CONTAINER}/src/cmd/mdgen/mdgen.go
|
|
||||||
MDGEN_BINARY := ${CORSO_BUILD_BIN}/mdgen
|
MDGEN_BINARY := ${CORSO_BUILD_BIN}/mdgen
|
||||||
CLI_DOCS_CONTAINER := ${CORSO_REPO_CONTAINER}/docs/docs/cli
|
CLI_DOCS := ${CORSO_REPO}/docs/docs/cli
|
||||||
|
|
||||||
buildimage:
|
buildimage:
|
||||||
docker build -t "alcion/docs:latest" .
|
docker build -t "alcion/docs:latest" .
|
||||||
|
|
||||||
dev: genclidocs
|
dev: genclidocs
|
||||||
docker run --rm -it \
|
$(DOCSC) npm start -- --host 0.0.0.0
|
||||||
-p 3000:3000 \
|
|
||||||
-v ${PWD}:/usr/src/docs alcion/docs
|
|
||||||
|
|
||||||
VALE_TARGET ?= docs README.md
|
VALE_TARGET ?= docs README.md
|
||||||
|
|
||||||
dockercheck: genclidocs
|
|
||||||
docker run --rm \
|
|
||||||
-v ${PWD}:/usr/src/docs alcion/docs vale $(VALE_TARGET)
|
|
||||||
docker run --rm \
|
|
||||||
-v ${PWD}:/usr/src/docs alcion/docs markdownlint '**/*.md' --ignore styles/ --ignore src/ --ignore node_modules/
|
|
||||||
|
|
||||||
check: genclidocs
|
check: genclidocs
|
||||||
vale $(VALE_TARGET)
|
$(DOCSC) vale $(VALE_TARGET)
|
||||||
markdownlint '**/*.md' --ignore styles/ --ignore src/ --ignore node_modules/
|
$(DOCSC) markdownlint '**/*.md' --ignore styles/ --ignore src/ --ignore node_modules/
|
||||||
|
|
||||||
shell:
|
dockershell:
|
||||||
docker run --rm -it \
|
$(DOCSE) /bin/bash
|
||||||
-p 3000:3000 \
|
|
||||||
-v ${PWD}:/usr/src/docs alcion/docs /bin/bash
|
|
||||||
|
|
||||||
build: genclidocs
|
build: genclidocs
|
||||||
docker run --rm \
|
$(DOCSC) npm run build
|
||||||
-v ${PWD}:/usr/src/docs alcion/docs npm run build
|
|
||||||
|
|
||||||
genclidocs: ${MDGEN_BINARY}
|
genclidocs: ${MDGEN_BINARY}
|
||||||
@echo 'Auto-generating Corso CLI docs...'
|
@echo 'Auto-generating Corso CLI docs...'
|
||||||
rm -rf docs/cli
|
$(DOCSC) rm -rf docs/cli
|
||||||
docker run --rm -it \
|
$(GOC) ${MDGEN_BINARY} --cli-folder ${CLI_DOCS}
|
||||||
-v ${CORSO_REPO}:${CORSO_REPO_CONTAINER} -v ${CORSO_BUILD_DIR}:${CORSO_BUILD_DIR} \
|
|
||||||
--workdir ${CORSO_REPO_CONTAINER}/src \
|
|
||||||
--entrypoint ${MDGEN_BINARY} \
|
|
||||||
golang:1.18 \
|
|
||||||
--cli-folder ${CLI_DOCS_CONTAINER}
|
|
||||||
|
|
||||||
${MDGEN_BINARY}: $(shell find ../src -type f -name *.go) $(shell find ../src -type d )
|
_validatemdgen: # in case we have a different architecture
|
||||||
|
${MDGEN_BINARY} --help >/dev/null || rm -rf ${MDGEN_BINARY}
|
||||||
|
|
||||||
|
${MDGEN_BINARY}: $(shell find ${CORSO_LOCAL_PATH}/src -type f -name *.go) $(shell find ${CORSO_LOCAL_PATH}/src -type d ) _validatemdgen
|
||||||
@echo 'Re-building Corso CLI docs auto-gen tooling...'
|
@echo 'Re-building Corso CLI docs auto-gen tooling...'
|
||||||
docker run --rm -it \
|
$(GOC) go mod download
|
||||||
-v ${CORSO_REPO}:${CORSO_REPO_CONTAINER} -v ${CORSO_BUILD_DIR}:${CORSO_BUILD_DIR} \
|
$(GOC) go build -o ${MDGEN_BINARY} ${MDGEN_SRC}
|
||||||
--env GOCACHE=${CORSO_BUILD_CACHE} --env GOMODCACHE=${CORSO_BUILD_MOD} --env GOTMPDIR=${CORSO_BUILD_DIR} \
|
|
||||||
--workdir ${CORSO_REPO_CONTAINER}/src \
|
clean:
|
||||||
--entrypoint /usr/local/go/bin/go \
|
$(DOCSC) rm -rf docs/cli
|
||||||
golang:1.18 \
|
$(DOCSC) rm -rf ${CORSO_BUILD_DIR}
|
||||||
mod download
|
|
||||||
docker run --rm -it \
|
|
||||||
-v ${CORSO_REPO}:${CORSO_REPO_CONTAINER} -v ${CORSO_BUILD_DIR}:${CORSO_BUILD_DIR} \
|
|
||||||
--env GOCACHE=${CORSO_BUILD_CACHE} --env GOMODCACHE=${CORSO_BUILD_MOD} --env GOTMPDIR=${CORSO_BUILD_DIR} \
|
|
||||||
--workdir ${CORSO_REPO_CONTAINER}/src \
|
|
||||||
--entrypoint /usr/local/go/bin/go \
|
|
||||||
golang:1.18 \
|
|
||||||
build -o ${MDGEN_BINARY} ${MDGEN_SRC_CONTAINER}
|
|
||||||
@ -25,5 +25,6 @@ RUN yarn install \
|
|||||||
&& yarn cache clean \
|
&& yarn cache clean \
|
||||||
&& rm -f package.json yarn.lock
|
&& rm -f package.json yarn.lock
|
||||||
ENV PATH /usr/src/node_modules/.bin:$PATH
|
ENV PATH /usr/src/node_modules/.bin:$PATH
|
||||||
|
ENV NODE_MODULES_PATH ../
|
||||||
|
|
||||||
WORKDIR /usr/src/website
|
WORKDIR /usr/src/website
|
||||||
|
|||||||
@ -1,19 +1,22 @@
|
|||||||
.PHONY: buildimage dev shell build publish sync
|
.PHONY: buildimage dev shell build publish sync
|
||||||
|
|
||||||
|
WEBC := docker run --rm -it --init -p 5050:3000 -p 5051:3001 \
|
||||||
|
-v ${PWD}:/usr/src/website corso/website
|
||||||
|
ifeq (${CORSO_USE_DOCKER},-1)
|
||||||
|
WEBC :=
|
||||||
|
endif
|
||||||
|
|
||||||
buildimage:
|
buildimage:
|
||||||
docker build -t "corso/website:latest" .
|
docker build -t "corso/website:latest" .
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
docker run --rm -it --init -p 5050:3000 -p 5051:3001 \
|
$(WEBC) gulp
|
||||||
-v ${PWD}:/usr/src/website corso/website gulp
|
|
||||||
|
|
||||||
shell:
|
shell:
|
||||||
docker run --rm -it -p 5050:3000 -p 5051:3001 \
|
$(WEBC) /bin/bash
|
||||||
-v ${PWD}:/usr/src/website corso/website /bin/bash
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
docker run --rm -it --init \
|
$(WEBC) gulp build
|
||||||
-v ${PWD}:/usr/src/website corso/website gulp build
|
|
||||||
|
|
||||||
publish: build
|
publish: build
|
||||||
docker run -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY \
|
docker run -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY \
|
||||||
|
|||||||
@ -213,7 +213,7 @@ gulp.task('copy:all', function () {
|
|||||||
|
|
||||||
gulp.task('copy:libs', function () {
|
gulp.task('copy:libs', function () {
|
||||||
return gulp
|
return gulp
|
||||||
.src(npmdist({ nodeModulesPath: '../' }), { base: paths.base.node.dir })
|
.src(npmdist({ nodeModulesPath: process.env.NODE_MODULES_PATH || './' }), { base: paths.base.node.dir })
|
||||||
.pipe(rename(function (path) {
|
.pipe(rename(function (path) {
|
||||||
path.dirname = path.dirname.replace(/\/dist/, '').replace(/\\dist/, '');
|
path.dirname = path.dirname.replace(/\/dist/, '').replace(/\\dist/, '');
|
||||||
}))
|
}))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user