-
Notifications
You must be signed in to change notification settings - Fork 24
Add GitLab + GitLab Runner to dev environment #745
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
ed3daf0
Run GitLab in local dev environment
mvandenburgh 3a59af7
Add script to bootstrap gitlab dev instance
mvandenburgh 8dbc05f
Add info to README
mvandenburgh 29b7723
Update gitlab docker env vars
mvandenburgh c01fdf7
Add wait to init script
mvandenburgh 706678b
Add error handling to init-gitlab.sh
danlamanna 6f673de
Use arm64-compatible docker image for gitlab
danlamanna 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
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
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,63 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| # Wait for gitlab to be up | ||
| echo "Waiting for GitLab..." | ||
| until curl -s -f -o /dev/null "http://localhost:8080" | ||
| do | ||
| sleep 5 | ||
| done | ||
| echo "Done." | ||
|
|
||
| # Set root user password + create a personal access token for it | ||
| PERSONAL_ACCESS_TOKEN="insecure_token" | ||
| docker compose exec gitlab gitlab-rails runner " \ | ||
| print 'Updating root user password...'; \ | ||
| user = User.find_by(username: 'root'); \ | ||
| user.password = user.password_confirmation = 'deadbeef'; \ | ||
| user.save!; \ | ||
| puts ' done'; \ | ||
| print 'Creating personal access token...'; \ | ||
| token = User.find_by_username('root').personal_access_tokens.create( \ | ||
| scopes: [:api], \ | ||
| name: 'Docker admin token', \ | ||
| expires_at: 365.days.from_now, \ | ||
| ); \ | ||
| token.set_token('$PERSONAL_ACCESS_TOKEN'); \ | ||
| token.save!; \ | ||
| puts ' done';" | ||
|
|
||
| # Create a new runner via the GitLab API and save its token | ||
| RUNNER_TOKEN=$(docker compose exec gitlab curl \ | ||
| --silent \ | ||
| --request POST \ | ||
| --url "http://localhost/api/v4/user/runners" \ | ||
| --data "runner_type=instance_type" \ | ||
| --data "description=test" \ | ||
| --data "tag_list=test" \ | ||
| --header "PRIVATE-TOKEN: $PERSONAL_ACCESS_TOKEN" | jq -r '.token') | ||
|
|
||
| # Register the containerized gitlab runner using the previously acquired token | ||
| docker compose exec gitlab-runner gitlab-runner register \ | ||
| --non-interactive \ | ||
| --description "docker-runner" \ | ||
| --url "http://gitlab/" \ | ||
| --token "$RUNNER_TOKEN" \ | ||
| --executor "docker" \ | ||
| --docker-volumes=/var/run/docker.sock:/var/run/docker.sock \ | ||
| --docker-image=docker:20-dind | ||
|
|
||
| # Create a new project | ||
| docker compose exec gitlab curl \ | ||
| --request POST \ | ||
| --url "http://localhost/api/v4/projects" \ | ||
| --header "PRIVATE-TOKEN: $PERSONAL_ACCESS_TOKEN" \ | ||
| --header "Content-Type: application/json" \ | ||
| --data '{"name": "spack", "path": "spack"}' | ||
|
|
||
| # Push spack github repo to the new project | ||
| docker compose exec gitlab bash -c " \ | ||
| git clone https://github.com/spack/spack.git && \ | ||
| cd spack && \ | ||
| git remote add gitlab http://root:deadbeef@localhost/root/spack.git && \ | ||
| git push -u gitlab develop" | ||
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.
Uh oh!
There was an error while loading. Please reload this page.