Skip to content

Commit

Permalink
🔧 Updated deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Lubneuski committed Oct 11, 2024
1 parent 5e30da2 commit bca7212
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,4 @@ ENV/
# Terraform
.terraform
.terraform.lock.hcl
plan.tfplan
6 changes: 0 additions & 6 deletions deployment/docker-compose.ci.yml

This file was deleted.

1 change: 1 addition & 0 deletions deployment/scripts/app_config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJECT_NAME="kf-api-dataservice"
60 changes: 18 additions & 42 deletions deployment/scripts/cibuild
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/bin/bash
set -e
config_file=$(find . -name "app_config" | grep scripts)
echo "FOUND config file : $config_file"
echo "Check Docker version"
docker version
source $config_file
echo $PROJECT_NAME

if [[ -n "${ETL_DEBUG}" ]]; then
set -x
fi

function usage() {
echo -n \
Expand All @@ -8,61 +18,27 @@ Build application for staging or a release.
"
}

if [ ! -f deploy_config.txt ]; then
echo "Please create deploy_config.txt file"
exit 1
if [[ -z "${PROJECT_NAME}" ]]; then
echo "Please set project_name variable"
exit 1
fi
source deploy_config.txt

if [ -z ${GIT_COMMIT} ]; then
echo "Please Set GIT_COMMIT"
fi

if [ -z ${REPO_TO_DEPLOY} ]; then
echo "Please Set REPO_TO_DEPLOY(e.g. git@github.com:d3b-center/arc.git)"
fi

if [ -z ${PROJECT} ]; then
echo "Please Set PROJECT(e.g. arc)"
fi

rm -rf $PROJECT
git clone --depth 1 $REPO_TO_DEPLOY
cd ${PROJECT}

if [[ -z "${GIT_COMMIT}" ]]; then
echo "Please Specify which commit you would like to deploy for the application"
exit 1
if [[ -z "${ENVIRONMENT}" ]]; then
echo "Please set environment variable"
exit 1
fi

if [[ -n "${GIT_COMMIT}" ]]; then
GIT_COMMIT="${GIT_COMMIT:0:7}"
else
git checkout "{GIT_COMMIT}"
fi

if [[ -n "${GITHUB_SHA}" ]]; then
GITHUB_SHA="unknown"
fi

if [[ -n "${GITHUB_BASE_REF}" ]]; then
GITHUB_BASE_REF="unknown"
fi

if [[ -n "${GITHUB_RUN_ID}" ]]; then
GITHUB_RUN_ID="unknown"
GIT_COMMIT="$(git rev-parse --short HEAD)"
fi

if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
if [[ "${1:-}" == "--help" ]]; then
usage
else
# Build tagged container images
docker build -f agent/Dockerfile . --tag ${PROJECT}:agent-${GIT_COMMIT} --build-arg="GITHUB_SHA=${GITHUB_SHA}" --build-arg="GITHUB_BASE_REF=${GITHUB_BASE_REF}" --build-arg="GITHUB_RUN_ID=${GITHUB_RUN_ID}"
docker build -f gateway/Dockerfile . --tag ${PROJECT}:gateway-${GIT_COMMIT} --build-arg="GITHUB_SHA=${GITHUB_SHA}" --build-arg="GITHUB_BASE_REF=${GITHUB_BASE_REF}" --build-arg="GITHUB_RUN_ID=${GITHUB_RUN_ID}"
docker build -t ${PROJECT_NAME}:${GIT_COMMIT} .
fi
fi

cd ../
rm -rf ${PROJECT}

38 changes: 10 additions & 28 deletions deployment/scripts/cipublish
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,18 @@ function usage() {
Publish container images to Elastic Container Registry (ECR).
"
}
if [ -f deploy_config.txt ]; then
source deploy_config.txt
else
echo "Could not find deploy_config.txt"
exit 1
fi

ECR_REPO=${PROJECT}

config_file=$(find . -name "app_config" | grep scripts)
echo "FOUND config file : $config_file"
echo "Check Docker version"
docker version
source $config_file

rm -rf arc
git clone --depth 1 git@github.com:d3b-center/arc
cd $PROJECT

if [[ -z "${GIT_COMMIT}" ]]; then
echo "Please Specify which commit you would like to deploy for the application"
exit 1
fi
ECR_REPO=${PROJECT_NAME}

if [[ -n "${GIT_COMMIT}" ]]; then
GIT_COMMIT="${GIT_COMMIT:0:7}"
else
git checkout "{GIT_COMMIT}"
GIT_COMMIT="$(git rev-parse --short HEAD)"
fi

function amazon_ecr_login() {
Expand All @@ -53,20 +42,13 @@ function amazon_ecr_login() {
--username "${AUTHORIZATION_TOKEN%%:*}" \
--password-stdin "${ECR_REGISTRY}"
}

echo "####################"
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
if [[ "${1:-}" == "--help" ]]; then
usage
else
amazon_ecr_login
docker tag "${ECR_REPO}:agent-${GIT_COMMIT}" \
"${ECR_REGISTRY}/${ECR_REPO}:agent-${GIT_COMMIT}"
docker push "${ECR_REGISTRY}/${ECR_REPO}:agent-${GIT_COMMIT}"
docker tag "${ECR_REPO}:gateway-${GIT_COMMIT}" \
"${ECR_REGISTRY}/${ECR_REPO}:gateway-${GIT_COMMIT}"
docker push "${ECR_REGISTRY}/${ECR_REPO}:gateway-${GIT_COMMIT}"
docker tag "${ECR_REPO}:${GIT_COMMIT}" "${ECR_REGISTRY}/${ECR_REPO}:${GIT_COMMIT}"
docker push "${ECR_REGISTRY}/${ECR_REPO}:${GIT_COMMIT}"
fi
fi

cd ..
rm -rf arc
Binary file removed deployment/terraform/plan.tfplan
Binary file not shown.

0 comments on commit bca7212

Please sign in to comment.