Merge pull request #1314 from basecamp/flavorjones/minio-in-dev

Minio support in development
This commit is contained in:
Mike Dalessio
2025-10-14 19:12:34 -04:00
committed by GitHub
4 changed files with 62 additions and 1 deletions
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env ruby
#
# Make sure the bucket we rely upon in development exists.
# Configuration and credentials are in config/storage.yml
#
require_relative "../config/environment"
require "aws-sdk-s3"
# Load storage configuration
storage_config = YAML.load(ERB.new(File.read("config/storage.yml")).result)
minio_config = storage_config["devminio"]
bucket_name = minio_config["bucket"]
endpoint = minio_config["endpoint"]
access_key = minio_config["access_key_id"]
secret_key = minio_config["secret_access_key"]
region = minio_config["region"]
# Create S3 client
s3_client = Aws::S3::Client.new(
endpoint: endpoint,
access_key_id: access_key,
secret_access_key: secret_key,
region: region,
force_path_style: minio_config["force_path_style"]
)
# Check if bucket exists
begin
s3_client.head_bucket(bucket: bucket_name)
puts "Bucket '#{bucket_name}' already exists"
rescue Aws::S3::Errors::NotFound
# Create the bucket
puts "Creating bucket '#{bucket_name}'..."
s3_client.create_bucket(bucket: bucket_name)
puts "Successfully created bucket '#{bucket_name}'"
rescue => e
puts "Error checking/creating bucket: #{e.message}"
exit 1
end
+6
View File
@@ -52,6 +52,12 @@ fi
bundle config set --local auto_install true
step "Installing RubyGems" bundle install
if [ -e tmp/minio-dev.txt ] ; then
step "Starting Docker services" bash -c "[ -d ~/Work/basecamp/docker-dev ] && git -C ~/Work/basecamp/docker-dev pull || gh repo clone basecamp/docker-dev ~/Work/basecamp/docker-dev && ~/Work/basecamp/docker-dev/setup minio"
step "Configuring MinIO" bin/minio-setup
fi
if [[ $* == *--reset* ]]; then
step "Resetting the database" rails db:reset
else
+5 -1
View File
@@ -32,7 +32,11 @@ Rails.application.configure do
end
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
if Rails.root.join("tmp/minio-dev.txt").exist?
config.active_storage.service = :devminio
else
config.active_storage.service = :local
end
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
+11
View File
@@ -6,6 +6,17 @@ local:
service: Disk
root: <%= Rails.root.join("storage", "tenants", Rails.env, "%{tenant}", "files") %>
devminio:
service: S3
bucket: fizzy-dev-activestorage
endpoint: "http://minio.localhost:39000"
force_path_style: true
request_checksum_calculation: when_required # default is when_supported with CRC64NVME checksum which FlashBlade doesn't support
response_checksum_validation: when_required # default is when_supported with CRC64NVME checksum which FlashBlade doesn't support
region: us-east-1 # default region required for signer
access_key_id: minioadmin
secret_access_key: minioadmin
# We have "development", "staging", and "production" buckets configured. Note that we don't have a
# "beta" bucket. (As of 2025-06-01.)
purestorage: