-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Add Docker image for auto-indexing support. #160
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d092830
WIP: Add auto-indexing support.
varungandhi-src a1299ba
WIP: Read gem name and version from metadata file.
varungandhi-src 7b22037
WIP: Use Ruby 2.7.6 base image not 3.x
varungandhi-src 1f5469e
docs: Add docs on the Docker image
varungandhi-src 2f8cc92
docs: Add some comments in the Dockerfile.
varungandhi-src efb095c
ci: Add Docker tags for patch/minor/major versions too
varungandhi-src 9284844
lint: Fix actionlint warning for >> duplication.
varungandhi-src File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| name: 'Publish Docker' | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: 'Tag to publish Docker image for (scip-ruby-vM.N.P)' | ||
| workflow_run: | ||
| workflows: ['Release'] | ||
| types: | ||
| - completed | ||
|
|
||
| jobs: | ||
| release-image: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: | | ||
| if [ -z "$TAG" ]; then | ||
| # From https://stackoverflow.com/questions/10649814/get-last-git-tag-from-a-remote-repo-without-cloning | ||
| TAG="$(git -c 'versionsort.suffix=-' \ | ||
| ls-remote --exit-code --refs --sort='version:refname' --tags https://github.com/sourcegraph/scip-ruby.git 'scip-ruby-v*' \ | ||
| | tail --lines=1 \ | ||
| | cut --delimiter='/' --fields=3)" | ||
| fi | ||
| { | ||
| echo "TAG=$TAG" | ||
| echo "PATCH=${TAG/scip-ruby-v/}" | ||
| echo "MINOR=${PATCH%.*}" | ||
| echo "MAJOR=${MINOR%.*}" | ||
| } >> "$GITHUB_ENV" | ||
| env: | ||
| TAG: ${{ inputs.tag }} | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| ref: ${{ env.TAG }} | ||
| - uses: docker/setup-buildx-action@v2 | ||
| - name: Login to DockerHub | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| username: ${{ secrets.DOCKER_USERNAME }} | ||
| password: ${{ secrets.DOCKER_PASSWORD }} | ||
| - name: Build and push | ||
| id: docker_build_autoindex | ||
| uses: docker/build-push-action@v3 | ||
| with: | ||
| file: Dockerfile.autoindex | ||
| push: true | ||
| tags: | | ||
| sourcegraph/scip-ruby:autoindex | ||
| sourcegraph/scip-typescript:autoindex-${{ env.PATCH }} | ||
| sourcegraph/scip-typescript:autoindex-${{ env.MINOR }} | ||
| sourcegraph/scip-typescript:autoindex-${{ env.MAJOR }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| name: Release | ||
| name: Release # This name is used by the publish-docker workflow | ||
| on: | ||
| push: | ||
| tags: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| FROM --platform=linux/amd64 ruby:2.7.6-alpine3.16@sha256:b014cf3e792d7130daec772241a211c40be009fc7f00e2b728ffe26805649575 | ||
|
|
||
| # This Docker image is meant for auto-indexing support in Sourcegraph | ||
| # and is not recommended for third-party use. | ||
|
|
||
| # gcompat is a glibc-musl compat library (scip-ruby links in glibc) | ||
| # Other deps are to help build C extensions in gems. | ||
| RUN apk add --no-cache bash wget make libstdc++ gcc g++ automake autoconf gcompat | ||
|
|
||
| # Use a release binary instead of building from source | ||
| # because release builds are very time-consuming. | ||
| # | ||
| # The release version is verified by tools/scripts/publish-scip-ruby.sh | ||
| RUN wget https://github.com/sourcegraph/scip-ruby/releases/download/scip-ruby-v0.3.0/scip-ruby-x86_64-linux -O /usr/bin/scip-ruby && chmod +x /usr/bin/scip-ruby | ||
|
|
||
| COPY scip_indexer/autoindex.sh /usr/bin/scip-ruby-autoindex | ||
|
|
||
| RUN chmod +x /usr/bin/scip-ruby-autoindex | ||
|
|
||
| CMD ["/bin/sh"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
| set -x | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| --gem-name) | ||
| GEM_NAME="$2" | ||
| shift # past argument | ||
| shift # past value | ||
| ;; | ||
| --gem-version) | ||
| GEM_VERSION="$2" | ||
| shift # past argument | ||
| shift # past value | ||
| ;; | ||
| --is-package) | ||
| IS_PACKAGE_REPO="YES" | ||
| shift # past argument | ||
| esac | ||
| done | ||
|
|
||
| initialize_sorbet() { | ||
| gem install "$GEM_NAME" -v "$GEM_VERSION" | ||
|
|
||
| # Assume that current directory is the gem root. | ||
| # `gem lock` will emit the current gem too, but we don't want that, | ||
| # as the root already has the source code. | ||
| # | ||
| # FIXME: Allow passing in gem source from the outside | ||
| # Blocked on https://github.com/sourcegraph/sourcegraph/issues/44204 | ||
| gem lock "$GEM_NAME-$GEM_VERSION" \ | ||
| | grep -v "gem '$GEM_NAME'" \ | ||
| | sed -E 's|^gem|source "https://rubygems.org"\ngem|' \ | ||
| > Gemfile | ||
|
|
||
| echo "group :development do | ||
| gem 'tapioca', require: false | ||
| end" >> Gemfile | ||
|
|
||
| bundle install | ||
| bundle exec tapioca init | ||
| } | ||
|
|
||
| # FIXME: Modify the global gem sources list to use the configured host | ||
| # in Sourcegraph rather than https://rubygems.org | ||
|
|
||
| # Created by Sourcegraph to indicate package repos. | ||
| if [ -f "rubygems-metadata.yml" ]; then | ||
| IS_PACKAGE_REPO="YES" | ||
| fi | ||
|
|
||
| if [ -n "${IS_PACKAGE_REPO:-}" ]; then | ||
| if [ -z "${GEM_NAME:-}" ]; then | ||
| GEM_NAME="$(grep 'name:' rubygems-metadata.yml | head -n 1 | sed -e 's/name: //')" | ||
| fi | ||
| if [ -z "${GEM_VERSION:-}" ]; then | ||
| GEM_VERSION="$(grep ' version:' rubygems-metadata.yml | head -n 1 | sed -e 's/ version: //')" | ||
| fi | ||
| initialize_sorbet | ||
| set +e | ||
| scip-ruby . --gem-metadata "$GEM_NAME@$GEM_VERSION" | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ -f "sorbet/config" ]; then | ||
| set +e | ||
| if [ -n "${GEM_NAME:-}" ] && [ -n "${GEM_VERSION:-}" ]; then | ||
| scip-ruby --gem-metadata "$GEM_NAME@$GEM_VERSION" | ||
| else | ||
| scip-ruby | ||
| fi | ||
| exit 0 | ||
| fi | ||
|
|
||
|
|
||
| set +e | ||
| # Can remove this once the 'default to using .' problem in | ||
| # https://github.com/sourcegraph/scip-ruby/issues/133 is fixed. | ||
| if [ -n "${GEM_NAME:-}" ] && [ -n "${GEM_VERSION:-}" ]; then | ||
| scip-ruby . --gem-metadata "$GEM_NAME@$GEM_VERSION" | ||
| else | ||
| scip-ruby . | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This scheme doesn't let us generate Docker images for older releases (I'd like to make one for 0.3.0) but maybe that's fine.