diff --git a/.github/workflows/push-container.yaml b/.github/workflows/push-container.yaml index 427ffc3..5d80a3e 100644 --- a/.github/workflows/push-container.yaml +++ b/.github/workflows/push-container.yaml @@ -4,7 +4,8 @@ on: workflow_dispatch: push: branches: - - main + # - main + - disabled_github_action env: AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID_PRIVADO_ID }} @@ -43,15 +44,15 @@ jobs: run: echo "::set-output name=VERSION::$(git rev-parse --short HEAD)" id: version - - name: Build with tag and push image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} - IMAGE_TAG: ${{ steps.version.outputs.VERSION }} - run: | - docker build \ - -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest \ - -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} . - - docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} - docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest + # - name: Build with tag and push image + # env: + # ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + # ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} + # IMAGE_TAG: ${{ steps.version.outputs.VERSION }} + # run: | + # docker build \ + # -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest \ + # -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} . + + # docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + # docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest diff --git a/Dockerfile b/Dockerfile index 1b0faf2..2e36ee3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,4 +27,9 @@ COPY --from=base /build/refresh-service refresh-service ENV CIRCUITS_FOLDER_PATH=/app/keys -ENTRYPOINT ["/app/refresh-service"] +# Wrapper +COPY entrypoint.sh /entrypoint.sh +RUN chmod 0755 /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["/app/refresh-service"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..b6386ab --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +SRC="/shared/env/app.env" +DST="/app/.env" + +if [ -f "$SRC" ]; then + cp "$SRC" "$DST" + chmod 0400 "$DST" || true +fi + +exec "$@" diff --git a/go.mod b/go.mod index 835cc86..4d9bd57 100644 --- a/go.mod +++ b/go.mod @@ -52,6 +52,7 @@ require ( github.com/iden3/go-rapidsnark/witness/v2 v2.0.0 // indirect github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e // indirect github.com/iden3/merkletree-proof v1.0.1 // indirect + github.com/joho/godotenv v1.5.1 // indirect github.com/lestrrat-go/blackmagic v1.0.4 // indirect github.com/lestrrat-go/httpcc v1.0.1 // indirect github.com/lestrrat-go/httprc v1.0.6 // indirect diff --git a/go.sum b/go.sum index d1a5c14..0cb9470 100644 --- a/go.sum +++ b/go.sum @@ -144,6 +144,8 @@ github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7Bd github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= github.com/jarcoal/httpmock v1.3.1/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= diff --git a/main.go b/main.go index 2c1ff93..76b80d6 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "github.com/0xPolygonID/refresh-service/server" "github.com/0xPolygonID/refresh-service/service" "github.com/iden3/go-schema-processor/v2/loaders" + "github.com/joho/godotenv" "github.com/kelseyhightower/envconfig" "github.com/piprate/json-gold/ld" "github.com/pkg/errors" @@ -72,6 +73,11 @@ func (c *Config) getSupportedIssuers() map[string]string { func main() { var cfg Config + + if err := godotenv.Load(); err != nil { + log.Printf("Error loading .env file: %v", err) + } + if err := envconfig.Process("", &cfg); err != nil { log.Fatalf("failed init config: %v", err) }