Skip to content

Commit

Permalink
Cleaner build method
Browse files Browse the repository at this point in the history
  • Loading branch information
ARIC LASRY authored and ARIC LASRY committed Nov 23, 2023
1 parent 94c5ec6 commit 5397a6f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-front.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Build the image on Cloud Build
run: |
chmod +x ./k8s/cloud-build.sh
./k8s/cloud-build.sh front
./k8s/cloud-build.sh front ./front/Dockerfile ../
- name: Deploy the image on Kubernetes
run: |
Expand Down
7 changes: 4 additions & 3 deletions k8s/cloud-build.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/sh
# first arg : name of image to build
# second arg (optional) : working directory. If not provided, it defaults to "../$1"
# second arg: path to the Dockerfile, relative to the resolved WORKING_DIR.
# thid arg (optional) : working directory. If not provided, it defaults to "../$1"
set -e

SCRIPT_DIR="$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd)"
WORKING_DIR="${2:-${SCRIPT_DIR}/../$1}"
WORKING_DIR="${3:-${SCRIPT_DIR}/../$1}"

# Change the current working directory to the directory in which to build the image
cd "$WORKING_DIR"
Expand All @@ -14,4 +15,4 @@ echo "Current working directory is $(pwd)"

# Start the build and get its ID
echo "Starting build..."
BUILD_ID=$(gcloud builds submit --quiet --config "${SCRIPT_DIR}/cloudbuild.yaml" --substitutions=SHORT_SHA=$(git rev-parse --short HEAD),_IMAGE_NAME=$1 --format='value(id)' ../)
BUILD_ID=$(gcloud builds submit --quiet --config "${SCRIPT_DIR}/cloudbuild.yaml" --substitutions=SHORT_SHA=$(git rev-parse --short HEAD),_IMAGE_NAME=$1,DOCKERFILE_PATH=$2 --format='value(id)' .)
2 changes: 1 addition & 1 deletion k8s/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ steps:
- gcr.io/$PROJECT_ID/${_IMAGE_NAME}-image:latest
- --push
- -f
- ./front/Dockerfile
- ${DOCKERFILE_PATH}
- .
secretEnv: ["DEPOT_TOKEN"]

Expand Down

0 comments on commit 5397a6f

Please sign in to comment.