From a436059a29962ff3c2bba0562c1fd9d3584108b8 Mon Sep 17 00:00:00 2001 From: Luigi Date: Mon, 12 Feb 2024 20:35:51 +0100 Subject: [PATCH] fix: wrong field check, add new deploy's secrets --- Dockerfile | 17 ++++++++++++----- cmd/index/create.go | 2 +- scripts/deploy.sh | 10 +++++++--- 3 files changed, 20 insertions(+), 9 deletions(-) mode change 100644 => 100755 scripts/deploy.sh diff --git a/Dockerfile b/Dockerfile index dfa6e43..5547a83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,17 +26,24 @@ WORKDIR /data COPY --from=builder /app/main /app/main ARG UNCONDITIONAL_API_SOURCE_REPO -ARG UNCONDITIONAL_API_LOG_ENV -ENV UNCONDITIONAL_API_SOURCE_REPO=${UNCONDITIONAL_API_SOURCE_REPO} -ENV UNCONDITIONAL_API_LOG_ENV=${UNCONDITIONAL_API_LOG_ENV} +ARG UNCONDITIONAL_API_SOURCE_CLIENT_KEY ARG UNCONDITIONAL_API_FEED_REPO_INDEX ARG UNCONDITIONAL_API_FEED_REPO_HOST ARG UNCONDITIONAL_API_FEED_REPO_KEY +ARG UNCONDITIONAL_API_LOG_ENV + +ENV UNCONDITIONAL_API_SOURCE_REPO=${UNCONDITIONAL_API_SOURCE_REPO} +ENV UNCONDITIONAL_API_SOURCE_CLIENT_KEY=${UNCONDITIONAL_API_SOURCE_CLIENT_KEY} ENV UNCONDITIONAL_API_FEED_REPO_INDEX=${UNCONDITIONAL_API_FEED_REPO_INDEX} ENV UNCONDITIONAL_API_FEED_REPO_HOST=${UNCONDITIONAL_API_FEED_REPO_HOST} ENV UNCONDITIONAL_API_FEED_REPO_KEY=${UNCONDITIONAL_API_FEED_REPO_KEY} +ENV UNCONDITIONAL_API_LOG_ENV=${UNCONDITIONAL_API_LOG_ENV} -RUN /app/main index create --name ${UNCONDITIONAL_API_FEED_REPO_INDEX} +RUN --mount=type=secret,id=UNCONDITIONAL_API_SOURCE_CLIENT_KEY \ + --mount=type=secret,id=UNCONDITIONAL_API_FEED_REPO_KEY \ + UNCONDITIONAL_API_SOURCE_CLIENT_KEY="$(cat /run/secrets/UNCONDITIONAL_API_SOURCE_CLIENT_KEY)" \ + UNCONDITIONAL_API_FEED_REPO_KEY="$(cat /run/secrets/UNCONDITIONAL_API_FEED_REPO_KEY)" \ + /app/main index create --name feeds FROM scratch as release COPY --from=certificator /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ @@ -63,4 +70,4 @@ ENV UNCONDITIONAL_API_FEED_REPO_INDEX=${UNCONDITIONAL_API_FEED_REPO_INDEX} ENV UNCONDITIONAL_API_FEED_REPO_HOST=${UNCONDITIONAL_API_FEED_REPO_HOST} ENV UNCONDITIONAL_API_FEED_REPO_KEY=${UNCONDITIONAL_API_FEED_REPO_KEY} -ENTRYPOINT ["./app/main","serve", "--address", "0.0.0.0", "--port","8080", "--index","/data/index"] +ENTRYPOINT ["./app/main","serve", "--address", "0.0.0.0", "--port","8080"] diff --git a/cmd/index/create.go b/cmd/index/create.go index f9698f3..c75c286 100644 --- a/cmd/index/create.go +++ b/cmd/index/create.go @@ -40,7 +40,7 @@ func NewCreateCommand() *cobra.Command { } frk := cobrax.Flag[string](cmd, "feed-repo-key").(string) - if i == "" { + if frk == "" { return ErrFeedRepoKeyNotProvided } diff --git a/scripts/deploy.sh b/scripts/deploy.sh old mode 100644 new mode 100755 index 20cb69a..c64f89b --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -8,6 +8,10 @@ if ! command -v flyctl &> /dev/null; then fi # Deploy -flyctl deploy --build-secret UNCONDITIONAL_API_SOURCE_CLIENT_KEY="$UNCONDITIONAL_API_SOURCE_CLIENT_KEY" \ - --build-arg UNCONDITIONAL_API_BUILD_COMMIT_VERSION="$UNCONDITIONAL_API_BUILD_COMMIT_VERSION" \ - --build-arg UNCONDITIONAL_API_BUILD_RELEASE_VERSION="$UNCONDITIONAL_API_BUILD_RELEASE_VERSION" \ +flyctl deploy \ + --build-secret UNCONDITIONAL_API_SOURCE_CLIENT_KEY="$UNCONDITIONAL_API_SOURCE_CLIENT_KEY" \ + --build-secret UNCONDITIONAL_API_FEED_REPO_KEY="$UNCONDITIONAL_API_FEED_REPO_KEY" \ + --build-arg UNCONDITIONAL_API_FEED_REPO_HOST="$UNCONDITIONAL_API_FEED_REPO_HOST" \ + --build-arg UNCONDITIONAL_API_FEED_REPO_INDEX="$UNCONDITIONAL_API_FEED_REPO_INDEX" \ + --build-arg UNCONDITIONAL_API_BUILD_COMMIT_VERSION="$UNCONDITIONAL_API_BUILD_COMMIT_VERSION" \ + --build-arg UNCONDITIONAL_API_BUILD_RELEASE_VERSION="$UNCONDITIONAL_API_BUILD_RELEASE_VERSION"