From 4aa8ad8782f2c147b13538de036bd71506b38d3e Mon Sep 17 00:00:00 2001 From: vggonzal Date: Thu, 19 Oct 2023 14:17:58 -0700 Subject: [PATCH] docker config --- .github/workflows/build.yml | 33 ++++++++------------------------- build-lambda-zip.sh | 7 +++++++ build.sh | 26 -------------------------- terraform/hydrocron-main.tf | 1 - 4 files changed, 15 insertions(+), 52 deletions(-) create mode 100755 build-lambda-zip.sh delete mode 100755 build.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f81a72b2..993ceb10 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -163,7 +163,7 @@ jobs: # Setup docker to build and push images - name: Log in to the Container registry - # if: ${{ startsWith(github.ref, 'test') }} + #if: ${{ startsWith(github.ref, 'test') }} uses: docker/login-action@v1 with: registry: ${{ env.REGISTRY }} @@ -213,31 +213,14 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }} - run: aws sts get-caller-identity - - uses: hashicorp/setup-terraform@v2.0.3 - with: - terraform_version: 1.0.3 - - name: Deploy Terraform - #if: | - # github.ref == 'refs/heads/develop' || - # github.ref == 'refs/heads/main' || - # startsWith(github.ref, 'refs/heads/release') || - # github.event.head_commit.message == '/deploy sit' || - # github.event.head_commit.message == '/deploy uat' - working-directory: terraform/ + - name: Validate Terraform + run: terraform validate -no-color + + - name: Deploy to venue + id: terraform-deploy + working-directory: examples/cumulus-tf env: - AWS_ACCESS_KEY_ID: ${{ secrets[format('AWS_ACCESS_KEY_ID_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }} - AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }} AWS_DEFAULT_REGION: us-west-2 - - TF_VAR_hydrocron_api_api_docker_image: "ghcr.io/podaac/hydrocron:${{ env.THE_VERSION }}" - run: | - echo "--------" - echo ${{ env.THE_ENV }} - echo ${{ env.THE_VERSION }} - echo ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - terraform init -reconfigure -backend-config="bucket=podaac-services-sit-terraform" -backend-config="region=us-west-2" - terraform plan -var-file=tfvars/${{ env.THE_ENV }}.tfvars -var="app_version=${{ env.THE_VERSION }}" -out="tfplan" - terraform apply -auto-approve tfplan + ./bin/deploy.sh --app-version ${{ env.THE_VERSION }} --tf-venue ${{ vars.TF_VENUE }} --lambda_container_image_uri ${{ env.CONTAINER_IMAGE_URI }} \ No newline at end of file diff --git a/build-lambda-zip.sh b/build-lambda-zip.sh new file mode 100755 index 00000000..92db5754 --- /dev/null +++ b/build-lambda-zip.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -e + +rm -rf dist/lambda-package || true +mkdir -p dist/lambda-package +cp -r ./hydrocron-api dist/lambda-package/ +touch dist/lambda-package/hydrocron-api/__init__.py diff --git a/build.sh b/build.sh deleted file mode 100755 index d53a04bb..00000000 --- a/build.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -set -eo pipefail - -BUNDLE_PLUGIN_INSTALLED=$(poetry self show plugins | (grep 'poetry-plugin-bundle' || true) | wc -l) -if [ "$BUNDLE_PLUGIN_INSTALLED" -ne 1 ]; then - echo "Poetry bundle plugin missing! - https://github.com/python-poetry/poetry-plugin-bundle" - echo "Install the poetry bundle plugin with: poetry self add poetry-plugin-bundle" - exit 1 -fi - -PACKAGE_NAME=$(awk -F' = ' '{gsub(/"/,"");if($1=="name")print $2}' pyproject.toml) -VERSION=$(poetry version -s) - -ROOT_PATH="$PWD" -ZIP_PATH="$ROOT_PATH/dist/$PACKAGE_NAME-$VERSION-test.zip" - -poetry bundle venv build --clear --without=dev - -cd build/lib/python3.*/site-packages -touch hydrocron_api/__init__.py -rm -rf *.dist-info _virtualenv.* -find . -type d -name __pycache__ -exec rm -rf {} \+ - -mkdir -p "$ROOT_PATH/dist/" -rm -f "$ZIP_PATH" -zip -vr9 "$ZIP_PATH" . \ No newline at end of file diff --git a/terraform/hydrocron-main.tf b/terraform/hydrocron-main.tf index 2e0c2651..9507afe4 100644 --- a/terraform/hydrocron-main.tf +++ b/terraform/hydrocron-main.tf @@ -68,7 +68,6 @@ resource null_resource upload_ecr_image { provisioner "local-exec" { interpreter = ["/bin/bash", "-e", "-c"] command = <