Skip to content
Snippets Groups Projects
Commit 22600575 authored by Daniel Gruesso's avatar Daniel Gruesso
Browse files

Update build

parent 5aa3b1dc
No related branches found
No related tags found
No related merge requests found
Pipeline #72558038 passed
#!/usr/bin/env bash build:
stage: build
SOURCE="${BASH_SOURCE[0]}" image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-build-image/master:stable"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink services:
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - docker:stable-dind
SOURCE="$(readlink "$SOURCE")" script:
[[ $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 if [[ -z "$CI_COMMIT_TAG" ]]; then
export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG}
export DEPLOY_ROOT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_SHA}
else
source "$DEPLOY_ROOT_DIR/src/common.bash" export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE}
export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_TAG}
echo "Checking docker engine..." fi
ensure_docker_engine - /build/build.sh
only:
docker rm -f "$CI_CONTAINER_NAME" &>/dev/null || true - branches
- tags
echo "Building application..."
if [[ -f Dockerfile ]]; then
echo "Building Dockerfile-based application..."
# Build Dockerfile
docker build -t "$CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG" .
else
# Build heroku-based application
echo "Building Heroku-based application using gliderlabs/herokuish docker image..."
docker run -i --name="$CI_CONTAINER_NAME" \
-v "$(pwd):/tmp/app:ro" \
-v "/cache/herokuish:/tmp/cache" \
gliderlabs/herokuish /bin/herokuish buildpack build
docker commit "$CI_CONTAINER_NAME" "$CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG"
docker rm "$CI_CONTAINER_NAME" >/dev/null
echo ""
# Create a start command, start `web`
echo "Configuring $CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG docker image..."
docker create --expose 5000 --env PORT=5000 \
--name="$CI_CONTAINER_NAME" \
"$CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG" \
/bin/herokuish procfile start web
docker commit "$CI_CONTAINER_NAME" "$CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG"
docker rm "$CI_CONTAINER_NAME" >/dev/null
echo ""
fi
if [[ -n "$CI_BUILD_TOKEN" ]]; then
echo "Logging to GitLab Container Registry with CI credentials..."
docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY"
echo ""
fi
echo "Pushing to GitLab Container Registry..."
docker push "$CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG"
echo ""
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment