Skip to content

Commit

Permalink
speed up local build (erda-project#186)
Browse files Browse the repository at this point in the history
* Add .dockerignore

* Add .dockerignore to optimize docker build context

* Identify `vendor` dir to optimize tidy phrase in Makefile

* Makefile: `build` phrase not depends on `prepare` phrase to speed local build

* Polish Makefile's step log
  • Loading branch information
sfwn authored Apr 14, 2021
1 parent be7c50c commit 773a718
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Files for ideas
.idea/*
*.iml

# Files for vim
.*.sw?

# Files for vscode
.vscode/*
.vendor/*

# build output
/bin
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ build-all:
done; \
echo "build all modules successfully!"

build: prepare build-version submodule tidy
build: build-version submodule tidy
cd "${BUILD_PATH}" && \
${GO_BUILD_ENV} go build ${VERSION_OPS} ${GO_BUILD_MUSL_TAGS} -o "${PROJ_PATH}/bin/${APP_NAME}"
echo "build the ${MODULE_PATH} module successfully!"
Expand All @@ -78,17 +78,24 @@ build-version:
@echo ------------ End Build Version Details ------------

tidy:
cd "${BUILD_PATH}" && \
${GO_BUILD_ENV} go mod tidy
@if [[ -f "${BUILD_PATH}/go.mod" ]]; then \
echo "go mod tidy: use module-level go.mod" && \
cd "${BUILD_PATH}" && ${GO_BUILD_ENV} go mod tidy; \
elif [[ -d "${PROJ_PATH}/vendor" ]]; then \
echo "go mod tidy: already have vendor dir, skip tidy" ; \
else \
echo "go mod tidy: use project-level go.mod" && \
cd "${PROJ_PATH}" && ${GO_BUILD_ENV} go mod tidy; \
fi

generate:
cd "${BUILD_PATH}" && \
${GO_BUILD_ENV} go generate -v -x

prepare:
cd "${PROJ_PATH}" && \
${GO_BUILD_ENV} go generate ./apistructs &&\
${GO_BUILD_ENV} go generate ./modules/openapi/api/generate &&\
${GO_BUILD_ENV} go generate ./apistructs && \
${GO_BUILD_ENV} go generate ./modules/openapi/api/generate && \
${GO_BUILD_ENV} go generate ./modules/openapi/component-protocol/generate

submodule:
Expand Down

0 comments on commit 773a718

Please sign in to comment.