Skip to content

Commit

Permalink
Merge pull request #623 from hikaya-io/ISS-620
Browse files Browse the repository at this point in the history
ISS-620: Fix image build error on staging
  • Loading branch information
Darius-Ndubi authored May 22, 2020
2 parents 2ad9155 + f76fbe3 commit 4b7dde8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
14 changes: 7 additions & 7 deletions ci-scripts/build_docker_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build_and_push_image() {
echo export ACTIVITY_CE_DB_HOST=${ACTIVITY_CE_DB_HOST_DEV} >> .env.deploy
echo export ACTIVITY_CE_DB_PORT=${ACTIVITY_CE_DB_PORT_DEV} >> .env.deploy

docker build -t $REGISTRY_OWNER/activity:$APPLICATION_NAME-$APPLICATION_ENV-$TRAVIS_COMMIT -f docker-deploy/Dockerfile .
docker build -t $REGISTRY_OWNER/activity:$APPLICATION_NAME-$APPLICATION_ENV-$TRAVIS_COMMIT -f docker-deploy/Dockerfile .
echo "-------- Building Image Done! ----------"

echo "++++++++++++ Push Image built -------"
Expand All @@ -51,7 +51,7 @@ build_and_push_image() {

if [[ $TRAVIS_BRANCH == "staging" ]] || \
[[ $GITHUB_REF == "refs/heads/staging" ]]; then
ECHO "++++++ Build Staging Image +++++++++++"
echo "++++++ Build Staging Image +++++++++++"

#@--- Run export function ---@#
export_variables
Expand All @@ -63,7 +63,7 @@ build_and_push_image() {
echo export ACTIVITY_CE_DB_PORT=${ACTIVITY_CE_DB_PORT_DEV} >> .env.deploy
export APPLICATION_ENV=${APPLICATION_ENV_STAGING}

docker build -t $REGISTRY_OWNER/activity:$APPLICATION_NAME-$APPLICATION_ENV-$TRAVIS_COMMIT -f docker-deploy/Dockerfile .
docker build -t $REGISTRY_OWNER/activity:$APPLICATION_NAME-$APPLICATION_ENV-$TRAVIS_COMMIT -f docker-deploy/Dockerfile .
echo "-------- Building Image Done! ----------"

echo "++++++++++++ Push Image built -------"
Expand All @@ -76,7 +76,7 @@ build_and_push_image() {
if [[ $GITHUB_EVENT_NAME == "release" ]] || [[ ! -z $TRAVIS_TAG ]]; then

# Create prod settings file and modify dockerfile for production image
old_line='mv /app/activity/settings/local-sample.py /app/activity/settings/local.py'
old_line='mv /app/activity/settings/local-sample.py /app/activity/settings/local.py'
new_line='echo yes | python manage.py collectstatic'
sed -i "s%$old_line%$new_line%g" docker-deploy/Dockerfile
sed -i "s/DEBUG = True/DEBUG = False/" activity/settings/local-sample.py
Expand All @@ -86,7 +86,7 @@ build_and_push_image() {
new_email_config="EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'"
sed -i "s%$old_email_config%$new_email_config%g" activity/settings/local.py
sed -i "s%$old_email_config%$new_email_config%g" activity/settings/production.py

echo "+++++++++++ Build Production Image +++++++++++++"

#@--- Run export function ---@#
Expand All @@ -99,7 +99,7 @@ build_and_push_image() {
echo export ACTIVITY_CE_DB_PORT=${ACTIVITY_CE_DB_PORT_PROD} >> .env.deploy
export APPLICATION_ENV=${APPLICATION_ENV_PROD}

docker build -t $REGISTRY_OWNER/activity:$APPLICATION_NAME-$APPLICATION_ENV-$TRAVIS_COMMIT -f docker-deploy/Dockerfile .
docker build -t $REGISTRY_OWNER/activity:$APPLICATION_NAME-$APPLICATION_ENV-$TRAVIS_COMMIT -f docker-deploy/Dockerfile .
echo "-------- Building Image Done! ----------"

echo "++++++++++++ Push Image built -------"
Expand All @@ -109,7 +109,7 @@ build_and_push_image() {

#@--- Logout from docker ---@#
echo "--------- Logout dockerhub --------"
docker logout
docker logout
}


Expand Down
10 changes: 5 additions & 5 deletions ci-scripts/create_infrastructure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set_up_cluster_dev_env() {
-var "postgres_version=$PG_VERSION" \
-var "db_name=$DB_NAME_DEV_ENV" \
-var "tags=$PROJECT_NAME"

#@--- Apply the changes ---@#
echo "+++++ Apply infrastructure ++++++++++"
terraform apply -lock=false -auto-approve -var "cluster_name=$CLUSTER_NAME_DEV_ENV" \
Expand Down Expand Up @@ -88,7 +88,7 @@ set_up_cluster_staging() {
-var "tags=$PROJECT_NAME" \
|| echo "Resources exist"
fi

}

#@--- Function to setup production cluster ---@#
Expand Down Expand Up @@ -116,7 +116,7 @@ set_up_cluster_prod() {
-var "postgres_version=$PG_VERSION" \
-var "db_name=$DB_NAME_PROD" \
-var "tags=$PROJECT_NAME"

#@--- Apply the changes ---@#
echo "+++++ Apply infrastructure ++++++++++"
terraform apply -lock=false -auto-approve -target=digitalocean_kubernetes_cluster.cluster \
Expand All @@ -140,7 +140,7 @@ main() {
cd infrastructure

if [[ $TRAVIS_EVENT_TYPE != "pull_request" ]]; then

#@--- Run the setup dev-env cluster function ---@#
set_up_cluster_dev_env

Expand All @@ -150,7 +150,7 @@ main() {
#@--- Run the prod setup function ---@#
set_up_cluster_prod
fi

}

#@--- Run the main function ---@#
Expand Down
20 changes: 10 additions & 10 deletions ci-scripts/deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ install_kubectl_doctl() {
# Add binary to path
sudo mv ./kubectl /usr/local/bin/kubectl

# Check the version
# Check the version
kubectl version --client

# Install digital ocean cli tool
Expand All @@ -43,7 +43,7 @@ auth_kubectl_cluster() {
kubectl create namespace $APPLICATION_ENV || echo "++++++ Namespace Exists ++++++"
kubectl create namespace ingress-nginx || echo "++++++ Namespace ingress-nginx Exists ++++++"
fi

# fetch cluster nodes
kubectl get nodes

Expand Down Expand Up @@ -77,26 +77,26 @@ deploy_app() {

echo "+++++++ make deployments with kubectl +++++++"
kubectl create clusterrolebinding serviceaccounts-cluster-admin --clusterrole=cluster-admin --group=system:serviceaccounts
kubectl apply -f deployment_files/man.yaml
kubectl apply -f deployment_files/man.yaml
kubectl apply --validate=false -f deployment_files/cert-config/cert-manager-0.12.0.yaml
kubectl apply --validate=false -f deployment_files/metrics-server.yaml
sleep 70

kubectl apply -f deployment_files/ingress-service.yaml
kubectl apply -f cert-secret.yaml
kubectl apply -f deployment_files/ingress-service.yaml
kubectl apply -f cert-secret.yaml
kubectl apply --validate=false -f cert-issuer.yaml
kubectl apply --validate=false -f certificate.yaml
kubectl apply -f deployment.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl apply -f autoscaler.yaml
kubectl apply -f ingress-config.yaml
kubectl apply -f autoscaler.yaml
kubectl apply -f ingress-config.yaml
echo "--------- deployment made !! ----------------"
fi
}

#@--- Function to replace some key variables ---@#
replace_variables() {

#@--- Replace necesary variables for dev env ---@#
if [[ $TRAVIS_BRANCH == "dev" ]] || \
[[ $GITHUB_REF == "refs/heads/dev" ]]; then
Expand All @@ -122,7 +122,7 @@ replace_variables() {

#@--- Main Function ---@#
main() {

if [[ $TRAVIS_EVENT_TYPE != "pull_request" ]]; then
#@--- Run install and setup function ---@#
install_kubectl_doctl
Expand Down

0 comments on commit 4b7dde8

Please sign in to comment.