From 0912b84fbd5f1ddd9d6257050b1147c6cee415b6 Mon Sep 17 00:00:00 2001 From: "benjamin.747" Date: Tue, 10 Feb 2026 11:45:32 +0800 Subject: [PATCH] add new buck2hub env --- .gitignore | 4 +- api/.dockerignore | 1 + api/Dockerfile | 2 + api/README.md | 2 +- .../credentials/staging-buck2hub.yml.enc | 1 + api/config/database.yml | 18 +++ api/config/environments/staging-buck2hub.rb | 118 ++++++++++++++++++ {script => api/script}/demo/README.md | 0 .../script}/demo/build-images-arm64-local.sh | 2 +- 9 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 api/config/credentials/staging-buck2hub.yml.enc create mode 100644 api/config/environments/staging-buck2hub.rb rename {script => api/script}/demo/README.md (100%) rename {script => api/script}/demo/build-images-arm64-local.sh (99%) mode change 100644 => 100755 diff --git a/.gitignore b/.gitignore index a15c788..20d994d 100644 --- a/.gitignore +++ b/.gitignore @@ -79,9 +79,7 @@ api/config/credentials/production.key api/config/credentials/development.key api/config/credentials/development.yml.enc -api/config/credentials/staging.key -api/config/credentials/staging-nju.key -api/config/credentials/staging-openatom.key +api/config/credentials/**.key # Ignore ngrok.yaml, we'll generate from ngrok.yml.template api/ngrok.yaml diff --git a/api/.dockerignore b/api/.dockerignore index aace13d..d1d18b5 100644 --- a/api/.dockerignore +++ b/api/.dockerignore @@ -11,5 +11,6 @@ db/*.sqlite3-* storage config/master.key +config/credentials/**.key node_modules diff --git a/api/Dockerfile b/api/Dockerfile index 4e41f78..9c89778 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -83,6 +83,8 @@ ENV MALLOC_CONF=dirty_decay_ms:1000,narenas:2,background_thread:true COPY . . +RUN rm -f config/credentials/*.key + RUN SECRET_KEY_BASE=dummy bundle exec rails assets:precompile EXPOSE 8080 diff --git a/api/README.md b/api/README.md index 3222a91..6c423cb 100644 --- a/api/README.md +++ b/api/README.md @@ -9,7 +9,7 @@ This is the API that powers https://app.campsite.com ### Running the app -The API can be started with `script/server`. The API is accessible on http://api.gitmono.test:3001 and the frontend on http://app.gitmono.test:3000 (after you've run `vercel dev` in that repo). +The API can be started with `script/server`. The API is accessible on http://api.gitmono.test:3001 and the frontend on http://app.gitmono.test (after you've run `vercel dev` in that repo). ### Useful commands & shortcuts diff --git a/api/config/credentials/staging-buck2hub.yml.enc b/api/config/credentials/staging-buck2hub.yml.enc new file mode 100644 index 0000000..e25406e --- /dev/null +++ b/api/config/credentials/staging-buck2hub.yml.enc @@ -0,0 +1 @@ +iHydKk0Nt19J34bJuPjt+q5usM5yBZUKq2PMnlstTGxdna09bQF2u1o/+qQIBhgeojSnXsX2dY0eCn4HsLi/n7ckdiDk2ipYGYTl8oG2T5OceDSshqElgdA95hM0pwa/WVemk9cp+3KhXIkdpxKYA17hMuEiNLqLZv/3HpakusGcJwy6asU6IebTIi80pcwn3XGFzpPDMT6iRaZA5ZeeqNlqDOEs9nbXvh/dvrJvZlNP+p6hDAcQ69SRwDUKvF/Ub+vELQb5DVsMPNbowZDsYPVQKIlrAowwh/+Bn+hsvVVxisKX2UOhLkRLFFhrDpytp/B0bv3CBwtlteZyQEfCA4FNAIRsLC3M4Pjhr9SqW7hRMLxCNOt7yEgygu9M6f3Q9/S5nKMEV/gvdHqCXuo0SPZ2x7w0mWosaTyrwWpW7m3RyGM59kgsQZv7YJWKCltpbndd8E6zily76ZGZcze5pV1bc99GNmoryQB9Q6YBLeJV9hFROVNtdjPk1e8Ug9AZECPWcv7vxBErwIEJQcwKDmL5yls6GvyirOC6B/PPVIKMgQExdI3leOwjS9DsnjSN3Ibw8hpIT+VuiiThXYgAmVSLTtf60/2EdDh/m2vB4aImvMKGY4mSckBDBOGatnb9ewLdgYH+qCBmnGU+ydgirwxMk/7tCqlUJux3ZFq8wxkIHzQgWrgH4PGsk8afvVWFFuvU8d+ItkCAP8luyR3E9IfVa3jTj1JRr40dzqtpbThmGECEVFfTvaXZCjR/cWv0981pe1oAzsP9H72JtBmsKnTdK1p7xFhYPLfbvyRTPrkJTQUKFUcpqTCV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i/dqlSY21/BxnTlUvNiGkbVBQT6nH9+j8cacL77ud2XBeCHh16X6ohrnHhyvzXsLlNBEA8AIRpbWPari9aokyuCLTxuZJE9wb8Lbkl9ZvCsueBtDBz/84fsKnsfX8JsxPwHc+IC68pRkOVXsIc5BsTiYPi9HnMXlNuoO4XuN/xVmaSKNXNtTHA7NVVJwdJ5lrSEJECqMoKaRqDx/VaFsvxFCfiz1vE/3sZVMbAxpM+PcwXcICkqpNXbbIz5yBawfdWO0sZq1aF/GTmK4iQlD8SSQ414KWqPxTy+qS0hAgVGhjCJsHwO5ICcob8qBMC2Gs4bVsCJ0h9977Y5gY3xpD86GE1VVAxFyN5RmKDEQ8yU5tIlkI=--r+xjh2JdCrI31MIv--llg26lkrpnFQ8WutzzjrAQ== \ No newline at end of file diff --git a/api/config/database.yml b/api/config/database.yml index 1348053..d3e75d4 100644 --- a/api/config/database.yml +++ b/api/config/database.yml @@ -150,6 +150,24 @@ staging-gitmono: ssl_mode: required replica: true + staging-buck2hub: + primary: + <<: *default + username: <%= Rails.application.credentials.dig(:mysql, :username) %> + password: <%= Rails.application.credentials.dig(:mysql, :password) %> + database: campsite_api_buck2hub + host: <%= Rails.application.credentials.dig(:mysql, :host) %> + ssl_mode: required + + primary_replica: + <<: *default + username: <%= Rails.application.credentials.dig(:mysql, :username) %> + password: <%= Rails.application.credentials.dig(:mysql, :password) %> + database: campsite_api_buck2hub + host: <%= Rails.application.credentials.dig(:mysql, :host) %> + ssl_mode: required + replica: true + demo: primary: <<: *default diff --git a/api/config/environments/staging-buck2hub.rb b/api/config/environments/staging-buck2hub.rb new file mode 100644 index 0000000..8289363 --- /dev/null +++ b/api/config/environments/staging-buck2hub.rb @@ -0,0 +1,118 @@ +# frozen_string_literal: true + +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + config.console1984.protected_environments = [:production, :staging] + config.console1984.ask_for_username_if_empty = true + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? + + # Compress CSS using a preprocessor. + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache + # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX + + # Disable IP spoofing check since Fly.io's load balancer changes headers + config.action_dispatch.ip_spoofing_check = false + + # Store uploaded files on the local file system (see config/storage.yml for options). + # config.active_storage.service = :local + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [:request_id] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment). + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "campsite_api_production" + + config.action_mailer.perform_caching = false + config.action_mailer.default_url_options = { host: "buck2hub.com" } + config.action_mailer.delivery_method = :postmark + config.action_mailer.postmark_settings = { + api_token: Rails.application.credentials&.postmark&.api_token, + } + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + config.action_mailer.raise_delivery_errors = true + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = Logger::Formatter.new + + # Use a different logger for distributed setups. + # require "syslog/logger" + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new($stdout) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + config.active_record.async_query_executor = :global_thread_pool + + config.hosts << "admin.buck2hub.com" + config.hosts << "auth.buck2hub.com" + config.hosts << "api.buck2hub.com" + config.hosts << "buck2hub.com" + config.hosts << "localhost" + config.hosts << "127.0.0.1" + + config.hosts += [ + /10\.\d+\.\d+\.\d+/, + /172\.16\.\d+\.\d+/, + /172\.17\.\d+\.\d+/, + /172\.31\.\d+\.\d+/, + /192\.168\.\d+\.\d+/, + ] +end diff --git a/script/demo/README.md b/api/script/demo/README.md similarity index 100% rename from script/demo/README.md rename to api/script/demo/README.md diff --git a/script/demo/build-images-arm64-local.sh b/api/script/demo/build-images-arm64-local.sh old mode 100644 new mode 100755 similarity index 99% rename from script/demo/build-images-arm64-local.sh rename to api/script/demo/build-images-arm64-local.sh index e2c289d..f6ca30e --- a/script/demo/build-images-arm64-local.sh +++ b/api/script/demo/build-images-arm64-local.sh @@ -75,7 +75,7 @@ if ! docker buildx build \ --platform "$PLATFORM" \ --load \ -t "$IMAGE_NAME" \ - api \ + . \ --build-arg RUBY_VERSION="$RUBY_VERSION" \ --build-arg NODE_VERSION="$NODE_VERSION" \ --build-arg BUNDLER_VERSION="$BUNDLER_VERSION"; then