symbols: go-build only builds target binary
Created by: keegancsmith
Previously go-build.sh just built the full symbols docker image and then copied out the symbols binary. This did a lot of extra work, including building ctags. go-build.sh is called as part of building the server image, one of the slowest steps on the critical path in CI. It now just runs the build target in the Dockerfile.
There are multiple improvements to the Dockerfile. This change was motivated by switching to go1.18. Before this commit when using go1.18 the server build would fail in CI due to symbol's go-build.sh. I didn't fully root cause it, but I believe it had something to do with using alpine-3.14 as the builder image which included an older version of go.
This commits moves just symbols to use go1.18. Another commit will move everything else to go1.18.
These are the other improvements made in this commit:
- ARGs come last to prevent them invalidating caches.
- build target renamed to symbols-build to be more clear in CI.
- --no-cache used in apk add.
- ENTRYPOINT uses JSON args due to hadolint complaining.
- DOCKER_BUILDKIT=1 is set to simplify running locally.
Test Plan: main-dry-run on CI will exercise building the images and will run integration tests. To test locally I ran
VERSION=test PKG=github.com/sourcegraph/sourcegraph/enterprise/cmd/symbols ./cmd/symbols/go-build.sh /tmp