Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use go 1.13, replace glide with modules, add boilerplate docker_build
- removed bootstrap make target, since it was only needed to install glide and run glide install - updated Dockerfile stages to optimize dependency caching - update docker-compose to use the base stage of Dockerfile for consistency
- Loading branch information
Showing
15 changed files
with
302 additions
and
243 deletions.
There are no files selected for viewing
This file contains 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,11 +1,23 @@ | ||
sudo: required | ||
language: go | ||
go: "1.11" | ||
services: redis-server | ||
go: "1.13" | ||
services: | ||
- docker | ||
- redis-server | ||
before_install: sudo apt-get update -y && sudo apt-get install stunnel4 -y | ||
install: make bootstrap bootstrap_redis_tls | ||
before_script: | ||
install: make bootstrap_redis_tls | ||
before_script: | ||
- redis-server --port 6380 & | ||
- redis-server --port 6381 --requirepass password123 & | ||
- redis-server --port 6382 --requirepass password123 & | ||
script: make check_format tests | ||
script: make check_format tests docker_build | ||
jobs: | ||
include: | ||
- stage: test | ||
- stage: release | ||
if: tag IS present && !fork | ||
script: skip | ||
deploy: | ||
provider: script | ||
script: make docker_build dockerhub_push | ||
|
This file contains 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 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 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 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,12 @@ | ||
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES. | ||
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY: | ||
# | ||
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst | ||
|
||
.PHONY: docker_build | ||
docker_build: | ||
IMAGE_NAME=$$REPOSITORY ./boilerplate/lyft/docker_build/docker_build.sh | ||
|
||
.PHONY: dockerhub_push | ||
dockerhub_push: | ||
IMAGE_NAME=lyft/$$REPOSITORY REGISTRY=docker.io ./boilerplate/lyft/docker_build/docker_build.sh |
This file contains 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,23 @@ | ||
Docker Build and Push | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Provides a ``make docker_build`` target that builds your image locally. | ||
|
||
Provides a ``make dockerhub_push`` target that pushes your final image to Dockerhub. | ||
|
||
The Dockerhub image will tagged ``<REPOSITORY>:<GIT COMMIT SHA>`` | ||
|
||
If git head has a git tag, the Dockerhub image will also be tagged ``<IMAGE>:<GIT_TAG>``. | ||
|
||
**To Enable:** | ||
|
||
Add ``lyft/docker_build`` to your ``boilerplate/update.cfg`` file. | ||
|
||
Add ``include boilerplate/lyft/docker_build/Makefile`` in your main ``Makefile`` _after_ your REPOSITORY environment variable | ||
|
||
:: | ||
|
||
REPOSITORY=<myreponame> | ||
include boilerplate/lyft/docker_build/Makefile | ||
|
||
(this ensures the extra Make targets get included in your main Makefile) |
This file contains 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,67 @@ | ||
#!/usr/bin/env bash | ||
|
||
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES. | ||
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY: | ||
# | ||
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst | ||
|
||
set -e | ||
|
||
echo "" | ||
echo "------------------------------------" | ||
echo " DOCKER BUILD" | ||
echo "------------------------------------" | ||
echo "" | ||
|
||
if [ -n "$REGISTRY" ]; then | ||
# Do not push if there are unstaged git changes | ||
CHANGED=$(git status --porcelain) | ||
if [ -n "$CHANGED" ]; then | ||
echo "Please commit git changes before pushing to a registry" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
|
||
GIT_SHA=$(git rev-parse HEAD) | ||
|
||
IMAGE_TAG_SUFFIX="" | ||
# for intermediate build phases, append -$BUILD_PHASE to all image tags | ||
if [ -n "$BUILD_PHASE" ]; then | ||
IMAGE_TAG_SUFFIX="-${BUILD_PHASE}" | ||
fi | ||
|
||
IMAGE_TAG_WITH_SHA="${IMAGE_NAME}:${GIT_SHA}${IMAGE_TAG_SUFFIX}" | ||
|
||
RELEASE_SEMVER=$(git describe --tags --exact-match "$GIT_SHA" 2>/dev/null) || true | ||
if [ -n "$RELEASE_SEMVER" ]; then | ||
IMAGE_TAG_WITH_SEMVER="${IMAGE_NAME}:${RELEASE_SEMVER}${IMAGE_TAG_SUFFIX}" | ||
fi | ||
|
||
# build the image | ||
# passing no build phase will build the final image | ||
docker build -t "$IMAGE_TAG_WITH_SHA" --target=${BUILD_PHASE} . | ||
echo "${IMAGE_TAG_WITH_SHA} built locally." | ||
|
||
# if REGISTRY specified, push the images to the remote registy | ||
if [ -n "$REGISTRY" ]; then | ||
|
||
if [ -n "${DOCKER_REGISTRY_PASSWORD}" ]; then | ||
docker login --username="$DOCKER_REGISTRY_USERNAME" --password="$DOCKER_REGISTRY_PASSWORD" | ||
fi | ||
|
||
docker tag "$IMAGE_TAG_WITH_SHA" "${REGISTRY}/${IMAGE_TAG_WITH_SHA}" | ||
|
||
docker push "${REGISTRY}/${IMAGE_TAG_WITH_SHA}" | ||
echo "${REGISTRY}/${IMAGE_TAG_WITH_SHA} pushed to remote." | ||
|
||
# If the current commit has a semver tag, also push the images with the semver tag | ||
if [ -n "$RELEASE_SEMVER" ]; then | ||
|
||
docker tag "$IMAGE_TAG_WITH_SHA" "${REGISTRY}/${IMAGE_TAG_WITH_SEMVER}" | ||
|
||
docker push "${REGISTRY}/${IMAGE_TAG_WITH_SEMVER}" | ||
echo "${REGISTRY}/${IMAGE_TAG_WITH_SEMVER} pushed to remote." | ||
|
||
fi | ||
fi |
This file contains 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 @@ | ||
lyft/docker_build |
This file contains 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,53 @@ | ||
#!/usr/bin/env bash | ||
|
||
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES. | ||
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY: | ||
# | ||
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst | ||
|
||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" | ||
|
||
OUT="$(mktemp -d)" | ||
git clone git@github.com:lyft/boilerplate.git "${OUT}" | ||
|
||
echo "Updating the update.sh script." | ||
cp "${OUT}/boilerplate/update.sh" "${DIR}/update.sh" | ||
echo "" | ||
|
||
|
||
CONFIG_FILE="${DIR}/update.cfg" | ||
README="https://github.com/lyft/boilerplate/blob/master/Readme.rst" | ||
|
||
if [ ! -f "$CONFIG_FILE" ]; then | ||
echo "$CONFIG_FILE not found." | ||
echo "This file is required in order to select which features to include." | ||
echo "See $README for more details." | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$REPOSITORY" ]; then | ||
echo '$REPOSITORY is required to run this script' | ||
echo "See $README for more details." | ||
exit 1 | ||
fi | ||
|
||
while read directory; do | ||
echo "***********************************************************************************" | ||
echo "$directory is configured in update.cfg." | ||
echo "-----------------------------------------------------------------------------------" | ||
echo "syncing files from source." | ||
dir_path="${OUT}/boilerplate/${directory}" | ||
rm -rf "${DIR}/${directory}" | ||
mkdir -p $(dirname "${DIR}/${directory}") | ||
cp -r "$dir_path" "${DIR}/${directory}" | ||
if [ -f "${DIR}/${directory}/update.sh" ]; then | ||
echo "executing ${DIR}/${directory}/update.sh" | ||
"${DIR}/${directory}/update.sh" | ||
fi | ||
echo "***********************************************************************************" | ||
echo "" | ||
done < "$CONFIG_FILE" | ||
|
||
rm -rf "${OUT}" |
This file contains 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
Oops, something went wrong.