From f99e3df5da984b64b5008748bc68d759e5a8673f Mon Sep 17 00:00:00 2001 From: Sheel-ui Date: Mon, 24 Jun 2024 16:14:51 +0530 Subject: [PATCH] init aws secret manager --- .github/workflows/deploy.yml | 3 +++ Dockerfile | 1 + start.sh | 1 + wait-for.sh | 22 ---------------------- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9e161db..9432b40 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,6 +27,9 @@ jobs: id: login-ecr uses: aws-actions/amazon-ecr-login@v1 + - name: Load secrets and save to app.env + run: aws secretsmanager get-secret-value --secret-id transactions_secret --query SecretString --output text | jq -r 'to_entries|map("\(.key)=\(.value)")|.[]' > app.env + - name: Build, tag, and push image to Amazon ECR env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} diff --git a/Dockerfile b/Dockerfile index 0d12411..356f54d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,7 @@ COPY app.env . COPY start.sh . COPY wait-for.sh . COPY db/migration ./migration +RUN chmod +x ./wait-for.sh EXPOSE 8080 CMD [ "/app/main" ] diff --git a/start.sh b/start.sh index 3a07a3c..c7bce1f 100644 --- a/start.sh +++ b/start.sh @@ -3,6 +3,7 @@ set -e echo "run db migration" +source /app/app.env /app/migrate -path /app/migration -database "$DB_SOURCE" -verbose up echo "start the app" diff --git a/wait-for.sh b/wait-for.sh index 266e1c2..d84e622 100644 --- a/wait-for.sh +++ b/wait-for.sh @@ -1,27 +1,5 @@ #!/bin/sh -# The MIT License (MIT) -# -# Copyright (c) 2017 Eficode Oy -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - set -- "$@" -- "$TIMEOUT" "$QUIET" "$PROTOCOL" "$HOST" "$PORT" "$result" TIMEOUT=15 QUIET=0