From 17de0cccea451e9570952004d5d37b9be42ab141 Mon Sep 17 00:00:00 2001 From: Simon Liu Date: Mon, 6 Jan 2025 16:26:56 -0800 Subject: [PATCH] /deploy sit --- .github/workflows/build.yml | 30 +++++++++++++++++++++++------- docker/lambdaDockerfileArm | 28 ++++++++++++++-------------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bd2f4db..d2a7730 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -87,23 +87,39 @@ jobs: - name: Build Package run: poetry build - - name: Check for Changes + - name: Quick check for changes id: check_changes if: | github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release') run: | - git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT + if [ -n "$(git status --porcelain)" ]; then + echo "changes=true" >> $GITHUB_OUTPUT + else + echo "changes=false" >> $GITHUB_OUTPUT + fi - - name: Git Operations + - name: Commit Version Bump if: steps.check_changes.outputs.changes == 'true' run: | git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" - git commit -am "/version ${{ env.new_version }}" - git tag -a "${{ env.new_version }}" -m "Version ${{ env.new_version }}" - git push --follow-tags + git commit -am "/version ${{ env.the_version }}" + git push + + - name: Push Tag + env: + VERSION: ${{ env.the_version }} + if: | + github.ref == 'refs/heads/develop' || + github.ref == 'refs/heads/main' || + startsWith(github.ref, 'refs/heads/release') + run: | + git config user.name "${GITHUB_ACTOR}" + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git tag -a "${VERSION}" -m "Version ${VERSION}" + git push origin "${VERSION}" - name: Create and Upload Release if: | @@ -119,7 +135,7 @@ jobs: prerelease: ${{ github.ref != 'refs/heads/main' }} publish: - needs: build + needs: Build & Publick Docker if: | success() && ( github.ref == 'refs/heads/develop' || diff --git a/docker/lambdaDockerfileArm b/docker/lambdaDockerfileArm index ed7503c..2c353af 100644 --- a/docker/lambdaDockerfileArm +++ b/docker/lambdaDockerfileArm @@ -1,25 +1,25 @@ -#ARG FUNCTION_DIR="/function" - +# Use the AWS Lambda base image for Python 3.11 (ARM64 architecture) FROM public.ecr.aws/lambda/python:3.11-arm64 -# Include global arg in this stage of the build +# Global build arguments ARG SOURCE +ARG DIST_PATH=dist/ +ENV LAMBDA_TASK_ROOT=/var/task -RUN yum -q -y install gcc - -# Create function directory -# RUN mkdir -p ${FUNCTION_DIR} -# WORKDIR ${FUNCTION_DIR} +# Install required packages +RUN yum -q -y install gcc || microdnf install gcc -# Install forge-py from artifactory +# Copy the distribution package into the container COPY $DIST_PATH $DIST_PATH -# install forge-py into working directory so we can call lambda -RUN pip3 install awslambdaric --target $LAMBDA_TASK_ROOT - -RUN pip3 install --no-cache-dir --force --index-url https://pypi.org/simple/ --extra-index-url https://test.pypi.org/simple/ --target "${LAMBDA_TASK_ROOT}" $SOURCE +# Install dependencies into the Lambda task root +RUN pip3 install awslambdaric --target $LAMBDA_TASK_ROOT \ + && pip3 install --no-cache-dir --force --index-url https://pypi.org/simple/ \ + --extra-index-url https://test.pypi.org/simple/ --target $LAMBDA_TASK_ROOT $SOURCE +# Remove the distribution files to reduce image size RUN rm -rf $DIST_PATH +# Lambda entry point and handler ENTRYPOINT [] -CMD ["podaac.lambda_handler.lambda_handler.handler"] \ No newline at end of file +CMD ["podaac.lambda_handler.lambda_handler.handler"]