-
-
Notifications
You must be signed in to change notification settings - Fork 62
Add scripts to build and publish docker image #141
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
2 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
|
|
@@ -23,7 +23,6 @@ dist/ | |
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
|
|
||
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,8 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -eu | ||
| # import util functions | ||
| source "${SCRIPTDIR}/../lib/util.sh" | ||
|
|
||
| echo "Building Docker image..." | ||
| runCommand "docker build -t $IMAGE_NAME -f Dockerfile ." || exit $? |
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,25 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Publishes the most recent web container to docker hubs repo. | ||
| # This script assumes docker push works. | ||
| # You must set up docker push on your own. | ||
|
|
||
| set -eu | ||
|
|
||
| DOCKER_REPO="operationcode/resources-api" | ||
|
|
||
| IMAGE_ID=$(docker images $IMAGE_NAME:latest --format "{{.ID}}") | ||
|
|
||
| if [ -n "$DOCKER_USERNAME" ]; then echo "Found username"; fi | ||
| if [ -n "$DOCKER_PASSWORD" ]; then echo "Found password"; fi | ||
|
|
||
| if [ -n "$DOCKER_USERNAME" ] && [ -n "$DOCKER_PASSWORD" ]; then | ||
| echo "Logging in using ENV creds" | ||
| docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" | ||
| fi | ||
|
|
||
| echo "Pushing image $IMAGE_NAME:$TRAVIS_BRANCH" | ||
| docker tag $IMAGE_ID $DOCKER_REPO | ||
| docker tag $IMAGE_ID ${DOCKER_REPO}:${TRAVIS_BUILD_NUMBER} | ||
| docker push $DOCKER_REPO | ||
| docker push ${DOCKER_REPO}:${TRAVIS_BUILD_NUMBER} |
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,38 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Only process first job in matrix (TRAVIS_JOB_NUMBER ends with ".1") | ||
| if [[ ! $TRAVIS_JOB_NUMBER =~ \.1$ ]]; then | ||
| echo "Skipping deploy since it's not the first job in matrix" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Don't process pull requests | ||
| # $TRAVIS_PULL_REQUEST will be the PR number or "false" if not a PR | ||
| if [[ -n "$TRAVIS_PULL_REQUEST" ]] && [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then | ||
| echo "Skipping deploy because it's a pull request" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Only process branches listed in DEPLOY_BRANCHES | ||
| BRANCHES_TO_DEPLOY=($DEPLOY_BRANCHES) | ||
| if [[ ! " ${BRANCHES_TO_DEPLOY[@]} " =~ " ${TRAVIS_BRANCH} " ]]; then | ||
| # whatever you want to do when arr contains value | ||
| echo "Skipping deploy, not a branch to be deployed" | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ $? = 0 ]; then | ||
|
|
||
| # Get absolute path of dir where run.sh is located | ||
| SOURCE="${BASH_SOURCE[0]}" | ||
| while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
| DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
| SOURCE="$(readlink "$SOURCE")" | ||
| [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
| done | ||
| export SCRIPTDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
|
||
| bash ${SCRIPTDIR}/build && | ||
| bash ${SCRIPTDIR}/publish | ||
|
|
||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| function isDryRun { | ||
| if [ "$DRYRUN" = "1" ]; then | ||
| return 0 | ||
| else | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| function runCommand { | ||
| if isDryRun; then | ||
| echo $1; | ||
| else | ||
| eval $1 | ||
| return $? | ||
| fi | ||
| } | ||
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.
Honestly think we could remove this entire file and not calling these wrappers.
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.
Let's do later.