s3arch 0.1.2 โ†’ 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b51661d90b5b65c15611e53f316b542cb6032dc34007adae6f8ee735baf6f0a3
4
- data.tar.gz: cacd1cc9bcab08dcb1bae6dc9e0f757bc7a014a1dc92d907a1e90e7d1e99eab3
3
+ metadata.gz: 86ab9ff26fb027515006bee668f41d7d5f264fc301110d57f6ac4d365b426588
4
+ data.tar.gz: bb2a513c4f7252620668c7292357d0e314a60d9efae70738c5ffd127f386d4b2
5
5
  SHA512:
6
- metadata.gz: c4bafc88643be123cfaf047d245679feae7881a3e2b75b0c8c90c445dc8be01a51be7aabb96d19a0760b47dee9f92f851c5c35f1547e806c9bb0b21a749a4009
7
- data.tar.gz: 7b137e16651e582d3b1a4582949133c91b992ea96b98659b11d415410b9bbf20edc5653b0614455c51b6b2f5a019292232fabb0732924e292130d6bfc59aeb8a
6
+ metadata.gz: 6def4b186fc609041e90c7246d1a9fb0453aeb01ae7c880040d9c8154a94eb514505adeab291191094c8e5e755e9fb753ccf699dd04cabccc672b0c7f74ad4cc
7
+ data.tar.gz: d1e054232f1d30443340ddd06f2a264458166b030a69b823327f82a61025f4065c000fadba2bbfc82d45949ee69b00e25d5be350d12a09309e4efab133d49503
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -145,16 +145,16 @@ S3arch requires the `sqlite3` native extension at runtime. A Rake task is includ
145
145
 
146
146
  ```bash
147
147
  # Build the layer zip (outputs to pkg/sqlite-layer.zip)
148
- rake lambda:build_layer
148
+ rake s3arch:layer:build
149
149
 
150
150
  # Build and publish in one step
151
- rake lambda:publish_layer PROFILE=devzilla
151
+ rake s3arch:layer:publish PROFILE=devzilla
152
152
 
153
153
  # Customize the build
154
- rake lambda:build_layer RUBY_VERSION=3.4 ARCHITECTURE=x86_64
154
+ rake s3arch:layer:build RUBY_VERSION=3.4 ARCHITECTURE=x86_64
155
155
 
156
156
  # Publish to a specific region/account
157
- rake lambda:publish_layer PROFILE=production REGION=us-west-2 LAYER_NAME=stowzilla-sqlite3-ruby
157
+ rake s3arch:layer:publish PROFILE=production REGION=us-west-2 LAYER_NAME=stowzilla-sqlite3-ruby
158
158
  ```
159
159
 
160
160
  | Environment Variable | Default | Description |
@@ -169,6 +169,21 @@ rake lambda:publish_layer PROFILE=production REGION=us-west-2 LAYER_NAME=stowzil
169
169
 
170
170
  Requires Docker to be running (uses the official AWS SAM build images).
171
171
 
172
+ ## Rake Tasks
173
+
174
+ ```bash
175
+ rake s3arch:layer:build # Build the Lambda layer zip
176
+ rake s3arch:layer:publish # Build and publish to AWS
177
+ rake s3arch:rebuild # Rebuild index for an owner (OWNER_ID=xxx)
178
+ rake s3arch:info # Show config and version info
179
+ ```
180
+
181
+ To make these tasks available in your app, add to your Rakefile:
182
+
183
+ ```ruby
184
+ require 's3arch/tasks'
185
+ ```
186
+
172
187
  ## Requirements
173
188
 
174
189
  - Ruby >= 3.2
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module S3arch
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
@@ -0,0 +1,148 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../s3arch/version'
4
+
5
+ namespace :s3arch do
6
+ namespace :layer do
7
+ desc 'Build the Lambda layer zip (defaults: RUBY_VERSION=3.4, ARCHITECTURE=x86_64)'
8
+ task :build do
9
+ require 'tmpdir'
10
+ require 'fileutils'
11
+
12
+ ruby_version = ENV.fetch('RUBY_VERSION', '3.4')
13
+ architecture = ENV.fetch('ARCHITECTURE', 'x86_64')
14
+ output_file = File.expand_path(ENV.fetch('OUTPUT', 'pkg/sqlite-layer.zip'))
15
+ s3arch_version = ENV.fetch('S3ARCH_VERSION', "~> #{S3arch::VERSION.sub(/\.\d+$/, '.0')}")
16
+
17
+ FileUtils.mkdir_p(File.dirname(output_file))
18
+
19
+ puts "๐Ÿ”จ Building Lambda layer (Ruby #{ruby_version} / #{architecture}, s3arch #{s3arch_version})..."
20
+
21
+ tmpdir = Dir.mktmpdir('s3arch-layer')
22
+ begin
23
+ File.write("#{tmpdir}/Gemfile", <<~GEMFILE)
24
+ source 'https://rubygems.org'
25
+ gem 'sqlite3', '~> 2.0'
26
+ gem 's3arch', '#{s3arch_version}'
27
+ GEMFILE
28
+
29
+ docker_image = "public.ecr.aws/sam/build-ruby#{ruby_version}:latest-#{architecture}"
30
+ platform = architecture == 'x86_64' ? 'linux/amd64' : 'linux/arm64'
31
+
32
+ build_script = <<~BASH
33
+ yum install -y sqlite-devel 2>/dev/null || dnf install -y sqlite-devel 2>/dev/null
34
+ bundle config set --local path /build/layer/ruby/gems/#{ruby_version}.0
35
+ bundle config set --local without "development test"
36
+ bundle config set --local deployment false
37
+ bundle install
38
+ NESTED="/build/layer/ruby/gems/#{ruby_version}.0/ruby/#{ruby_version}.0"
39
+ if [ -d "$NESTED" ]; then
40
+ mkdir -p /build/layer-final/ruby/gems/#{ruby_version}.0
41
+ cp -a "$NESTED"/* /build/layer-final/ruby/gems/#{ruby_version}.0/
42
+ rm -rf /build/layer
43
+ mv /build/layer-final /build/layer
44
+ fi
45
+ BASH
46
+
47
+ docker_cmd = [
48
+ 'docker', 'run', '--rm',
49
+ '--platform', platform,
50
+ '-v', "#{tmpdir}:/build",
51
+ '-w', '/build',
52
+ docker_image,
53
+ '/bin/bash', '-c', build_script
54
+ ]
55
+
56
+ puts "๐Ÿณ Building in Docker (#{docker_image})..."
57
+ abort 'โŒ Docker build failed' unless system(*docker_cmd)
58
+
59
+ layer_dir = "#{tmpdir}/layer"
60
+
61
+ puts '๐Ÿงน Stripping layer...'
62
+ Dir.glob("#{layer_dir}/ruby/gems/*/gems/*/").each do |gem_dir|
63
+ %w[spec test tests doc docs examples benchmarks].each do |fat_dir|
64
+ FileUtils.rm_rf("#{gem_dir}#{fat_dir}")
65
+ end
66
+ end
67
+
68
+ junk_patterns = %w[
69
+ *.md *.rdoc *.txt *.c *.h *.o Makefile *.log
70
+ CHANGELOG* HISTORY* LICENSE* README* .gitignore Rakefile
71
+ ]
72
+ junk_patterns.each do |pattern|
73
+ Dir.glob("#{layer_dir}/**/#{pattern}").each { |f| FileUtils.rm_f(f) }
74
+ end
75
+
76
+ Dir.glob("#{layer_dir}/**/*.so").each do |so|
77
+ system('strip', '--strip-debug', so, err: File::NULL)
78
+ end
79
+
80
+ sqlite_so = Dir.glob("#{layer_dir}/**/sqlite3_native.so") +
81
+ Dir.glob("#{layer_dir}/**/sqlite3.so")
82
+ abort 'โŒ sqlite3 native extension NOT found in layer' if sqlite_so.empty?
83
+ puts 'โœ… sqlite3 native extension included'
84
+
85
+ s3arch_lib = Dir.glob("#{layer_dir}/**/gems/s3arch-*/lib/s3arch.rb")
86
+ abort 'โŒ s3arch gem NOT found in layer' if s3arch_lib.empty?
87
+ puts 'โœ… s3arch gem included'
88
+
89
+ FileUtils.rm_f(output_file)
90
+ abort 'โŒ Failed to create zip' unless system('zip', '-qr', output_file, 'ruby/', chdir: layer_dir)
91
+
92
+ size = `du -h #{output_file}`.split("\t").first
93
+ puts "โœ… Layer built: #{output_file} (#{size})"
94
+ ensure
95
+ system('sudo', 'rm', '-rf', tmpdir) || FileUtils.rm_rf(tmpdir)
96
+ end
97
+ end
98
+
99
+ desc 'Build and publish the Lambda layer (set AWS_PROFILE, LAYER_NAME=stowzilla-sqlite3-ruby)'
100
+ task publish: :build do
101
+ layer_name = ENV.fetch('LAYER_NAME', 'stowzilla-sqlite3-ruby')
102
+ ruby_version = ENV.fetch('RUBY_VERSION', '3.4')
103
+ architecture = ENV.fetch('ARCHITECTURE', 'x86_64')
104
+ output_file = File.expand_path(ENV.fetch('OUTPUT', 'pkg/sqlite-layer.zip'))
105
+
106
+ abort "โŒ Layer zip not found at #{output_file}" unless File.exist?(output_file)
107
+
108
+ cmd = %w[aws lambda publish-layer-version]
109
+ cmd += ['--layer-name', layer_name]
110
+ cmd += ['--zip-file', "fileb://#{output_file}"]
111
+ cmd += ['--compatible-runtimes', "ruby#{ruby_version}"]
112
+ cmd += ['--compatible-architectures', architecture]
113
+
114
+ puts "๐Ÿ“ค Publishing layer '#{layer_name}'..."
115
+ puts " #{cmd.join(' ')}"
116
+
117
+ abort 'โŒ Failed to publish layer' unless system(*cmd)
118
+
119
+ puts 'โœ… Layer published successfully'
120
+ end
121
+ end
122
+
123
+ desc 'Rebuild the search index for a given owner: rake s3arch:rebuild[owner-123]'
124
+ task :rebuild, [:owner_id] do |_t, args|
125
+ require 's3arch'
126
+
127
+ owner_id = args.owner_id || ENV.fetch('OWNER_ID', nil)
128
+ abort 'โŒ Usage: rake s3arch:rebuild[OWNER_ID]' unless owner_id
129
+
130
+ S3arch.configure { |c| c.from_env! }
131
+
132
+ puts "๐Ÿ”„ Rebuilding index for #{owner_id}..."
133
+ S3arch::Indexer.new.rebuild(owner_id)
134
+ puts 'โœ… Done'
135
+ end
136
+
137
+ desc 'Show current s3arch configuration and version info'
138
+ task :info do
139
+ require 's3arch'
140
+
141
+ puts "s3arch #{S3arch::VERSION}"
142
+ puts ''
143
+ puts 'Environment:'
144
+ %w[S3ARCH_SOURCE_TABLE S3ARCH_SOURCE_INDEX S3ARCH_INDEX_BUCKET S3ARCH_VERSION_TABLE].each do |var|
145
+ puts " #{var}=#{ENV.fetch(var, '(not set)')}"
146
+ end
147
+ end
148
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3arch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Dalton
@@ -134,7 +134,7 @@ files:
134
134
  - lib/s3arch/tokenizer.rb
135
135
  - lib/s3arch/version.rb
136
136
  - lib/s3arch/web.rb
137
- - lib/tasks/lambda_layer.rake
137
+ - lib/tasks/s3arch.rake
138
138
  homepage: https://github.com/stowzilla/s3arch
139
139
  licenses:
140
140
  - MIT
metadata.gz.sig CHANGED
Binary file
@@ -1,134 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../s3arch/version'
4
-
5
- namespace :lambda do
6
- desc 'Build the Lambda layer zip (sqlite3 + s3arch) for deployment'
7
- task :build_layer do
8
- require 'tmpdir'
9
- require 'fileutils'
10
-
11
- ruby_version = ENV.fetch('RUBY_VERSION', '3.4')
12
- architecture = ENV.fetch('ARCHITECTURE', 'x86_64')
13
- output_file = File.expand_path(ENV.fetch('OUTPUT', 'pkg/sqlite-layer.zip'))
14
- s3arch_version = ENV.fetch('S3ARCH_VERSION', "~> #{S3arch::VERSION.sub(/\.\d+$/, '.0')}")
15
-
16
- FileUtils.mkdir_p(File.dirname(output_file))
17
-
18
- puts "๐Ÿ”จ Building Lambda layer (Ruby #{ruby_version} / #{architecture}, s3arch #{s3arch_version})..."
19
-
20
- tmpdir = Dir.mktmpdir('s3arch-layer')
21
- begin
22
- # Write a minimal Gemfile for the layer
23
- File.write("#{tmpdir}/Gemfile", <<~GEMFILE)
24
- source 'https://rubygems.org'
25
- gem 'sqlite3', '~> 2.0'
26
- gem 's3arch', '#{s3arch_version}'
27
- GEMFILE
28
-
29
- docker_image = "public.ecr.aws/sam/build-ruby#{ruby_version}:latest-#{architecture}"
30
- platform = architecture == 'x86_64' ? 'linux/amd64' : 'linux/arm64'
31
-
32
- build_script = <<~BASH
33
- yum install -y sqlite-devel 2>/dev/null || dnf install -y sqlite-devel 2>/dev/null
34
- bundle config set --local path /build/layer/ruby/gems/#{ruby_version}.0
35
- bundle config set --local without "development test"
36
- bundle config set --local deployment false
37
- bundle install
38
- # Flatten bundler's nested ruby/X.Y.0 structure into the layer root
39
- NESTED="/build/layer/ruby/gems/#{ruby_version}.0/ruby/#{ruby_version}.0"
40
- if [ -d "$NESTED" ]; then
41
- mkdir -p /build/layer-final/ruby/gems/#{ruby_version}.0
42
- cp -a "$NESTED"/* /build/layer-final/ruby/gems/#{ruby_version}.0/
43
- rm -rf /build/layer
44
- mv /build/layer-final /build/layer
45
- fi
46
- BASH
47
-
48
- docker_cmd = [
49
- 'docker', 'run', '--rm',
50
- '--platform', platform,
51
- '-v', "#{tmpdir}:/build",
52
- '-w', '/build',
53
- docker_image,
54
- '/bin/bash', '-c', build_script
55
- ]
56
-
57
- puts "๐Ÿณ Building in Docker (#{docker_image})..."
58
- abort 'โŒ Docker build failed' unless system(*docker_cmd)
59
-
60
- layer_dir = "#{tmpdir}/layer"
61
-
62
- # Strip unnecessary files to reduce layer size
63
- puts '๐Ÿงน Stripping layer...'
64
- Dir.glob("#{layer_dir}/ruby/gems/*/gems/*/").each do |gem_dir|
65
- %w[spec test tests doc docs examples benchmarks].each do |fat_dir|
66
- FileUtils.rm_rf("#{gem_dir}#{fat_dir}")
67
- end
68
- end
69
-
70
- junk_patterns = %w[
71
- *.md *.rdoc *.txt *.c *.h *.o Makefile *.log
72
- CHANGELOG* HISTORY* LICENSE* README* .gitignore Rakefile
73
- ]
74
- junk_patterns.each do |pattern|
75
- Dir.glob("#{layer_dir}/**/#{pattern}").each { |f| FileUtils.rm_f(f) }
76
- end
77
-
78
- # Strip debug symbols from shared objects
79
- Dir.glob("#{layer_dir}/**/*.so").each do |so|
80
- system('strip', '--strip-debug', so, err: File::NULL)
81
- end
82
-
83
- # Verify native extension is present
84
- sqlite_so = Dir.glob("#{layer_dir}/**/sqlite3_native.so") +
85
- Dir.glob("#{layer_dir}/**/sqlite3.so")
86
- abort 'โŒ sqlite3 native extension NOT found in layer' if sqlite_so.empty?
87
- puts 'โœ… sqlite3 native extension included'
88
-
89
- # Verify s3arch gem is present
90
- s3arch_lib = Dir.glob("#{layer_dir}/**/gems/s3arch-*/lib/s3arch.rb")
91
- abort 'โŒ s3arch gem NOT found in layer' if s3arch_lib.empty?
92
- puts 'โœ… s3arch gem included'
93
-
94
- # Package the zip
95
- FileUtils.rm_f(output_file)
96
- abort 'โŒ Failed to create zip' unless system('zip', '-qr', output_file, 'ruby/', chdir: layer_dir)
97
-
98
- size = `du -h #{output_file}`.split("\t").first
99
- puts "โœ… Layer built: #{output_file} (#{size})"
100
- ensure
101
- # Docker creates files as root; use sudo rm to clean up
102
- system('sudo', 'rm', '-rf', tmpdir) || FileUtils.rm_rf(tmpdir)
103
- end
104
- end
105
-
106
- desc 'Publish the Lambda layer to AWS (set PROFILE and REGION env vars)'
107
- task publish_layer: :build_layer do
108
- profile = ENV.fetch('PROFILE', nil)
109
- region = ENV.fetch('REGION', 'us-east-1')
110
- layer_name = ENV.fetch('LAYER_NAME', 'stowzilla-sqlite3-ruby')
111
- ruby_version = ENV.fetch('RUBY_VERSION', '3.4')
112
- architecture = ENV.fetch('ARCHITECTURE', 'x86_64')
113
- output_file = File.expand_path(ENV.fetch('OUTPUT', 'pkg/sqlite-layer.zip'))
114
-
115
- unless File.exist?(output_file)
116
- abort "โŒ Layer zip not found at #{output_file}. Run `rake lambda:build_layer` first."
117
- end
118
-
119
- cmd = %w[aws lambda publish-layer-version]
120
- cmd += ['--layer-name', layer_name]
121
- cmd += ['--zip-file', "fileb://#{output_file}"]
122
- cmd += ['--compatible-runtimes', "ruby#{ruby_version}"]
123
- cmd += ['--compatible-architectures', architecture]
124
- cmd += ['--region', region]
125
- cmd += ['--profile', profile] if profile
126
-
127
- puts "๐Ÿ“ค Publishing layer '#{layer_name}' to #{region}..."
128
- puts " #{cmd.join(' ')}"
129
-
130
- abort 'โŒ Failed to publish layer' unless system(*cmd)
131
-
132
- puts 'โœ… Layer published successfully'
133
- end
134
- end