Thanks to visit codestin.com
Credit goes to github.com

Skip to content

clean site/out and enforce make bin #2604

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

Merged
merged 1 commit into from
Jun 23, 2022
Merged
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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ bin: $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum

mkdir -p ./dist
rm -rf ./dist/coder-slim_*
rm -f ./site/out/bin/coder*
./scripts/build_go_slim.sh \
--compress 6 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this line do/why do we need it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From build_go_slim.sh: it compresses the coder-slim binaries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try to answer this @jsjoeio.

This is the PR that added the feature #2533, the motivation is to significantly reduce the size of "fat" binaries. We use level 6 for dev builds since it's very fast, 22 for prod builds which shaves an additional 20+MB. (You can see the effect on the releases page, comparing v0.7.3 binaries vs v0.7.4 😄)

I guess it's not strictly necessary to compress for make bin, though. Personally I think it's nice if they're prepared in case one does go build -tags embed during development, and it's closer to what we'd do with production builds too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! I agree, getting development and production builds to be as similar as possible seems like a good thing to aim for. Thank you both for explaining! Appreciate it 🙌🏼

--version "$(VERSION)" \
--output ./dist/ \
linux:amd64,armv7,arm64 \
Expand All @@ -31,6 +33,7 @@ bin: $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum
build: site/out/index.html $(shell find . -not -path './vendor/*' -type f -name '*.go') go.mod go.sum $(shell find ./examples/templates)
rm -rf ./dist
mkdir -p ./dist
rm -f ./site/out/bin/coder*

# build slim artifacts and copy them to the site output directory
./scripts/build_go_slim.sh \
Expand Down
13 changes: 10 additions & 3 deletions scripts/develop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ dependencies curl git go make yarn
curl --fail http://127.0.0.1:3000 >/dev/null 2>&1 && echo '== ERROR: something is listening on port 3000. Kill it and re-run this script.' && exit 1
curl --fail http://127.0.0.1:8080 >/dev/null 2>&1 && echo '== ERROR: something is listening on port 8080. Kill it and re-run this script.' && exit 1

echo '== Run "make build" before running this command to build binaries.'
echo '== Without these binaries, workspaces will fail to start!'
if [[ ! -e ./site/out/bin/coder.sha1 && ! -e ./site/out/bin/coder.tar.zst ]]; then
log
log "======================================================================="
log "== Run 'make bin' before running this command to build binaries. =="
log "== Without these binaries, workspaces will fail to start! =="
log "======================================================================="
log
exit 1
fi

# Run yarn install, to make sure node_modules are ready to go
"$PROJECT_ROOT/scripts/yarn_install.sh"
Expand All @@ -28,7 +35,7 @@ echo '== Without these binaries, workspaces will fail to start!'
# https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script
(
SCRIPT_PID=$$
cd "${PROJECT_ROOT}"
cdroot
CODERV2_HOST=http://127.0.0.1:3000 INSPECT_XSTATE=true yarn --cwd=./site dev || kill -INT -${SCRIPT_PID} &
go run -tags embed cmd/coder/main.go server --address 127.0.0.1:3000 --in-memory --tunnel || kill -INT -${SCRIPT_PID} &

Expand Down