From 73c8676304558edc3dc602c01a4cf09a22467511 Mon Sep 17 00:00:00 2001 From: Greg Delisle Date: Thu, 8 Aug 2024 14:17:28 -0400 Subject: [PATCH 01/11] Cap task installs env file from S3 using commit hash A yucky script, but it should grab the commit hash of "head" and then use that hash to grab the corresponding env file from S3. Currently always grabs the head hash and hard-codes the path within the int server. --- blacklight-cornell/deploy_rails_env_to_int.sh | 12 ++++++++++++ .../lib/capistrano/tasks/install_env.rake | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100755 blacklight-cornell/deploy_rails_env_to_int.sh diff --git a/blacklight-cornell/deploy_rails_env_to_int.sh b/blacklight-cornell/deploy_rails_env_to_int.sh new file mode 100755 index 000000000..a488936ee --- /dev/null +++ b/blacklight-cornell/deploy_rails_env_to_int.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + + +BUCKET='container-discovery' +img_id=$(git rev-parse head) + + +env_key="container_env_${img_id}" + +# this will only work on the integration server + +aws s3 cp s3://${BUCKET}/${env_key} /cul/web/catalog-int.library.cornell.edu/rails-app/shared/.env \ No newline at end of file diff --git a/blacklight-cornell/lib/capistrano/tasks/install_env.rake b/blacklight-cornell/lib/capistrano/tasks/install_env.rake index 7b550b8fa..87d06c4bc 100644 --- a/blacklight-cornell/lib/capistrano/tasks/install_env.rake +++ b/blacklight-cornell/lib/capistrano/tasks/install_env.rake @@ -3,7 +3,8 @@ task :install_env do on roles(:all) do within current_path do with rails_env: fetch(:rails_env, :stage) do - execute(:cp, "#{deploy_to}/../conf/latest-#{fetch(:rails_env, :stage)}.env", "#{shared_path}/.env") +# execute(:cp, "#{deploy_to}/../conf/latest-#{fetch(:rails_env, :stage)}.env", "#{shared_path}/.env") + execute(:current_path/deploy_rails_env_to_int.sh) end end end From 948d5f0b3fa0c8d4012d41d425ec69f78c0926cd Mon Sep 17 00:00:00 2001 From: Greg Delisle Date: Thu, 8 Aug 2024 14:22:37 -0400 Subject: [PATCH 02/11] Update install_env.rake --- blacklight-cornell/lib/capistrano/tasks/install_env.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blacklight-cornell/lib/capistrano/tasks/install_env.rake b/blacklight-cornell/lib/capistrano/tasks/install_env.rake index 87d06c4bc..67b2f8940 100644 --- a/blacklight-cornell/lib/capistrano/tasks/install_env.rake +++ b/blacklight-cornell/lib/capistrano/tasks/install_env.rake @@ -4,7 +4,7 @@ task :install_env do within current_path do with rails_env: fetch(:rails_env, :stage) do # execute(:cp, "#{deploy_to}/../conf/latest-#{fetch(:rails_env, :stage)}.env", "#{shared_path}/.env") - execute(:current_path/deploy_rails_env_to_int.sh) + execute("deploy_rails_env_to_int.sh") end end end From ec4ae752e1eec774b6b4ca540709f8475516841e Mon Sep 17 00:00:00 2001 From: Greg Delisle Date: Thu, 8 Aug 2024 14:31:44 -0400 Subject: [PATCH 03/11] Update install_env.rake --- blacklight-cornell/lib/capistrano/tasks/install_env.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blacklight-cornell/lib/capistrano/tasks/install_env.rake b/blacklight-cornell/lib/capistrano/tasks/install_env.rake index 67b2f8940..3fb5d857f 100644 --- a/blacklight-cornell/lib/capistrano/tasks/install_env.rake +++ b/blacklight-cornell/lib/capistrano/tasks/install_env.rake @@ -4,7 +4,7 @@ task :install_env do within current_path do with rails_env: fetch(:rails_env, :stage) do # execute(:cp, "#{deploy_to}/../conf/latest-#{fetch(:rails_env, :stage)}.env", "#{shared_path}/.env") - execute("deploy_rails_env_to_int.sh") + execute("#{deploy_to}/deploy_rails_env_to_int.sh") end end end From d8dc222ff8df98e9371e0d50a412f21dee5f3583 Mon Sep 17 00:00:00 2001 From: Greg Delisle Date: Thu, 8 Aug 2024 14:42:58 -0400 Subject: [PATCH 04/11] Update install_env.rake --- blacklight-cornell/lib/capistrano/tasks/install_env.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blacklight-cornell/lib/capistrano/tasks/install_env.rake b/blacklight-cornell/lib/capistrano/tasks/install_env.rake index 3fb5d857f..8dbce3bdc 100644 --- a/blacklight-cornell/lib/capistrano/tasks/install_env.rake +++ b/blacklight-cornell/lib/capistrano/tasks/install_env.rake @@ -4,7 +4,7 @@ task :install_env do within current_path do with rails_env: fetch(:rails_env, :stage) do # execute(:cp, "#{deploy_to}/../conf/latest-#{fetch(:rails_env, :stage)}.env", "#{shared_path}/.env") - execute("#{deploy_to}/deploy_rails_env_to_int.sh") + execute("./deploy_rails_env_to_int.sh") end end end From ea192f1fd90f544fa37cc0167a503af01b9f0233 Mon Sep 17 00:00:00 2001 From: Greg Delisle Date: Thu, 8 Aug 2024 14:46:34 -0400 Subject: [PATCH 05/11] Update install_env.rake --- blacklight-cornell/lib/capistrano/tasks/install_env.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blacklight-cornell/lib/capistrano/tasks/install_env.rake b/blacklight-cornell/lib/capistrano/tasks/install_env.rake index 8dbce3bdc..80384a4b6 100644 --- a/blacklight-cornell/lib/capistrano/tasks/install_env.rake +++ b/blacklight-cornell/lib/capistrano/tasks/install_env.rake @@ -4,7 +4,7 @@ task :install_env do within current_path do with rails_env: fetch(:rails_env, :stage) do # execute(:cp, "#{deploy_to}/../conf/latest-#{fetch(:rails_env, :stage)}.env", "#{shared_path}/.env") - execute("./deploy_rails_env_to_int.sh") + execute("#{deploy_to}/../conf/deploy_rails_env_to_int.sh") end end end From 13b7aa4fbda1e28184758a56ee288685218bb888 Mon Sep 17 00:00:00 2001 From: Greg Delisle Date: Thu, 8 Aug 2024 15:31:21 -0400 Subject: [PATCH 06/11] Update install_env.rake --- blacklight-cornell/lib/capistrano/tasks/install_env.rake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/blacklight-cornell/lib/capistrano/tasks/install_env.rake b/blacklight-cornell/lib/capistrano/tasks/install_env.rake index 80384a4b6..af1e51f64 100644 --- a/blacklight-cornell/lib/capistrano/tasks/install_env.rake +++ b/blacklight-cornell/lib/capistrano/tasks/install_env.rake @@ -4,7 +4,8 @@ task :install_env do within current_path do with rails_env: fetch(:rails_env, :stage) do # execute(:cp, "#{deploy_to}/../conf/latest-#{fetch(:rails_env, :stage)}.env", "#{shared_path}/.env") - execute("#{deploy_to}/../conf/deploy_rails_env_to_int.sh") +# execute("#{deploy_to}/../conf/deploy_rails_env_to_int.sh") + execute(:aws, "s3", "cp", "s3://container-discovery/container_env_latest.env", ""#{shared_path}/.env") end end end From dd6fe0ce9816d7e8373c4f9cacd786a5c9ad34f7 Mon Sep 17 00:00:00 2001 From: Greg Delisle Date: Thu, 8 Aug 2024 15:32:37 -0400 Subject: [PATCH 07/11] Update install_env.rake --- blacklight-cornell/lib/capistrano/tasks/install_env.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blacklight-cornell/lib/capistrano/tasks/install_env.rake b/blacklight-cornell/lib/capistrano/tasks/install_env.rake index af1e51f64..bfd8c8367 100644 --- a/blacklight-cornell/lib/capistrano/tasks/install_env.rake +++ b/blacklight-cornell/lib/capistrano/tasks/install_env.rake @@ -5,7 +5,7 @@ task :install_env do with rails_env: fetch(:rails_env, :stage) do # execute(:cp, "#{deploy_to}/../conf/latest-#{fetch(:rails_env, :stage)}.env", "#{shared_path}/.env") # execute("#{deploy_to}/../conf/deploy_rails_env_to_int.sh") - execute(:aws, "s3", "cp", "s3://container-discovery/container_env_latest.env", ""#{shared_path}/.env") + execute(:aws, "s3", "cp", "s3://container-discovery/container_env_latest.env", "#{shared_path}/.env") end end end From 4b5d54b26fb7cf6cfe8153fd8dbe38a2f32d9635 Mon Sep 17 00:00:00 2001 From: Greg Delisle Date: Thu, 8 Aug 2024 15:35:55 -0400 Subject: [PATCH 08/11] Update install_env.rake --- blacklight-cornell/lib/capistrano/tasks/install_env.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blacklight-cornell/lib/capistrano/tasks/install_env.rake b/blacklight-cornell/lib/capistrano/tasks/install_env.rake index bfd8c8367..f6ee82495 100644 --- a/blacklight-cornell/lib/capistrano/tasks/install_env.rake +++ b/blacklight-cornell/lib/capistrano/tasks/install_env.rake @@ -5,7 +5,7 @@ task :install_env do with rails_env: fetch(:rails_env, :stage) do # execute(:cp, "#{deploy_to}/../conf/latest-#{fetch(:rails_env, :stage)}.env", "#{shared_path}/.env") # execute("#{deploy_to}/../conf/deploy_rails_env_to_int.sh") - execute(:aws, "s3", "cp", "s3://container-discovery/container_env_latest.env", "#{shared_path}/.env") + execute("/usr/local/bin/aws", "s3", "cp", "s3://container-discovery/container_env_latest.env", "#{shared_path}/.env") end end end From ff53a0d08dd3625589a2ee85a6971e14b6b00991 Mon Sep 17 00:00:00 2001 From: Greg Delisle Date: Thu, 8 Aug 2024 15:38:32 -0400 Subject: [PATCH 09/11] Update install_env.rake --- blacklight-cornell/lib/capistrano/tasks/install_env.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blacklight-cornell/lib/capistrano/tasks/install_env.rake b/blacklight-cornell/lib/capistrano/tasks/install_env.rake index f6ee82495..be790600d 100644 --- a/blacklight-cornell/lib/capistrano/tasks/install_env.rake +++ b/blacklight-cornell/lib/capistrano/tasks/install_env.rake @@ -5,7 +5,7 @@ task :install_env do with rails_env: fetch(:rails_env, :stage) do # execute(:cp, "#{deploy_to}/../conf/latest-#{fetch(:rails_env, :stage)}.env", "#{shared_path}/.env") # execute("#{deploy_to}/../conf/deploy_rails_env_to_int.sh") - execute("/usr/local/bin/aws", "s3", "cp", "s3://container-discovery/container_env_latest.env", "#{shared_path}/.env") + execute("/usr/local/bin/aws", "s3", "cp", "s3://container-discovery/container_env_latest", "#{shared_path}/.env") end end end From 62018d7352348786de96db1bb632c6bb788a8c28 Mon Sep 17 00:00:00 2001 From: Greg Delisle Date: Thu, 8 Aug 2024 15:42:30 -0400 Subject: [PATCH 10/11] Cleanup --- blacklight-cornell/deploy_rails_env_to_int.sh | 12 ------------ .../lib/capistrano/tasks/install_env.rake | 2 -- 2 files changed, 14 deletions(-) delete mode 100755 blacklight-cornell/deploy_rails_env_to_int.sh diff --git a/blacklight-cornell/deploy_rails_env_to_int.sh b/blacklight-cornell/deploy_rails_env_to_int.sh deleted file mode 100755 index a488936ee..000000000 --- a/blacklight-cornell/deploy_rails_env_to_int.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - - -BUCKET='container-discovery' -img_id=$(git rev-parse head) - - -env_key="container_env_${img_id}" - -# this will only work on the integration server - -aws s3 cp s3://${BUCKET}/${env_key} /cul/web/catalog-int.library.cornell.edu/rails-app/shared/.env \ No newline at end of file diff --git a/blacklight-cornell/lib/capistrano/tasks/install_env.rake b/blacklight-cornell/lib/capistrano/tasks/install_env.rake index be790600d..1ffcdc7e4 100644 --- a/blacklight-cornell/lib/capistrano/tasks/install_env.rake +++ b/blacklight-cornell/lib/capistrano/tasks/install_env.rake @@ -3,8 +3,6 @@ task :install_env do on roles(:all) do within current_path do with rails_env: fetch(:rails_env, :stage) do -# execute(:cp, "#{deploy_to}/../conf/latest-#{fetch(:rails_env, :stage)}.env", "#{shared_path}/.env") -# execute("#{deploy_to}/../conf/deploy_rails_env_to_int.sh") execute("/usr/local/bin/aws", "s3", "cp", "s3://container-discovery/container_env_latest", "#{shared_path}/.env") end end From 61e9089ba686497af63e8c481e299e5f5a60e46a Mon Sep 17 00:00:00 2001 From: Greg Delisle Date: Thu, 8 Aug 2024 15:44:06 -0400 Subject: [PATCH 11/11] Update install_env.rake --- blacklight-cornell/lib/capistrano/tasks/install_env.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blacklight-cornell/lib/capistrano/tasks/install_env.rake b/blacklight-cornell/lib/capistrano/tasks/install_env.rake index 1ffcdc7e4..3a4cab185 100644 --- a/blacklight-cornell/lib/capistrano/tasks/install_env.rake +++ b/blacklight-cornell/lib/capistrano/tasks/install_env.rake @@ -3,7 +3,7 @@ task :install_env do on roles(:all) do within current_path do with rails_env: fetch(:rails_env, :stage) do - execute("/usr/local/bin/aws", "s3", "cp", "s3://container-discovery/container_env_latest", "#{shared_path}/.env") + execute("/usr/local/bin/aws", "s3", "cp", "s3://container-discovery/container_env_latest", "#{shared_path}/.env") end end end