From 4505c5dda3e95f0497e97a331dcd4f7763e6d1af Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Tue, 18 Apr 2023 00:35:35 +0530 Subject: [PATCH] chore: add build id to settings page (#6873) - Adds a build Id to the settings page --- .dockerignore | 2 -- .gitignore | 2 +- Procfile | 2 +- app/controllers/dashboard_controller.rb | 3 ++- .../routes/dashboard/settings/account/Index.vue | 3 +++ app/javascript/shared/store/globalConfig.js | 2 ++ config/initializers/git_sha.rb | 13 +++++++++++++ docker/Dockerfile | 10 +++++++++- 8 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 config/initializers/git_sha.rb diff --git a/.dockerignore b/.dockerignore index 85065ec7d..a5af77eb5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,6 @@ .bundle .env .env.* -.git -.gitignore docker-compose.* docker/Dockerfile docker/dockerfiles diff --git a/.gitignore b/.gitignore index 63d0781ca..e59f13b8f 100644 --- a/.gitignore +++ b/.gitignore @@ -61,7 +61,7 @@ test/cypress/videos/* /config/master.key /config/*.enc -.vscode/settings.json +#ignore files under .vscode directory .vscode # yalc for local testing diff --git a/Procfile b/Procfile index 3cfa8ae13..f281f018a 100644 --- a/Procfile +++ b/Procfile @@ -1,3 +1,3 @@ -release: POSTGRES_STATEMENT_TIMEOUT=600s bundle exec rails db:chatwoot_prepare +release: POSTGRES_STATEMENT_TIMEOUT=600s bundle exec rails db:chatwoot_prepare && echo $SOURCE_VERSION > .git_sha web: bundle exec rails ip_lookup:setup && bin/rails server -p $PORT -e $RAILS_ENV worker: bundle exec rails ip_lookup:setup && bundle exec sidekiq -C config/sidekiq.yml diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 25a981df6..ff6b5f57e 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -56,7 +56,8 @@ class DashboardController < ActionController::Base FB_APP_ID: GlobalConfigService.load('FB_APP_ID', ''), FACEBOOK_API_VERSION: 'v14.0', IS_ENTERPRISE: ChatwootApp.enterprise?, - AZURE_APP_ID: ENV.fetch('AZURE_APP_ID', '') + AZURE_APP_ID: ENV.fetch('AZURE_APP_ID', ''), + GIT_SHA: GIT_HASH } end end diff --git a/app/javascript/dashboard/routes/dashboard/settings/account/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/account/Index.vue index c04c1c76a..081d7a6f9 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/account/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/account/Index.vue @@ -104,6 +104,9 @@ }) }} +
+
{{ `Build ${globalConfig.gitSha}` }}
+
/app/.git_sha + # Remove unnecessary files RUN rm -rf /gems/ruby/3.1.0/cache/*.gem \ - && find /gems/ruby/3.1.0/gems/ \( -name "*.c" -o -name "*.o" \) -delete + && find /gems/ruby/3.1.0/gems/ \( -name "*.c" -o -name "*.o" \) -delete \ + && rm -rf .git \ + && rm .gitignore # final build stage FROM ruby:3.1.3-alpine3.16 @@ -100,6 +105,9 @@ RUN if [ "$RAILS_ENV" != "production" ]; then \ COPY --from=pre-builder /gems/ /gems/ COPY --from=pre-builder /app /app +# Copy .git_sha file from pre-builder stage +COPY --from=pre-builder /app/.git_sha /app/.git_sha + WORKDIR /app EXPOSE 3000