Initial commit

This commit is contained in:
2026-04-18 14:19:51 +04:00
commit f05b82ec21
4 changed files with 140 additions and 0 deletions

13
attributes/default.rb Normal file
View File

@@ -0,0 +1,13 @@
node.default['blossom']['repo_url'] = 'https://github.com/67P/blossom-server.git'
node.default['blossom']['revision'] = 'master'
node.default['blossom']['install_dir'] = '/opt/blossom'
node.default['blossom']['user'] = 'blossom'
node.default['blossom']['group'] = 'blossom'
node.default['blossom']['port'] = 3000
node.default['blossom']['host'] = '127.0.0.1'
node.default['blossom']['domain'] = 'blossom.example.com'
node.default['blossom']['allowed_pubkeys'] = []
node.default['blossom']['storage']['backend'] = 'local'
node.default['blossom']['storage']['local']['dir'] = "/home/#{node['blossom']['user']}/data/blobs"
node.default['blossom']['storage']['s3'] = {}

4
metadata.rb Normal file
View File

@@ -0,0 +1,4 @@
name 'blossom'
description 'Installs/Configures blossom server'
version '0.1.0'
depends 'deno'

80
recipes/default.rb Normal file
View File

@@ -0,0 +1,80 @@
include_recipe 'deno'
user node['blossom']['user'] do
home "/home/#{node['blossom']['user']}"
manage_home true
system true
end
group node['blossom']['group'] do
members [node['blossom']['user']]
system true
end
directory node['blossom']['install_dir'] do
owner node['blossom']['user']
group node['blossom']['group']
mode '0755'
end
git node['blossom']['install_dir'] do
repository node['blossom']['repo_url']
revision node['blossom']['revision']
action :sync
user node['blossom']['user']
group node['blossom']['group']
notifies :restart, 'service[blossom]', :delayed
end
directory "/home/#{node['blossom']['user']}/data" do
owner node['blossom']['user']
group node['blossom']['group']
mode '0750'
recursive true
end
template "#{node['blossom']['install_dir']}/config.yml" do
source 'config.yml.erb'
owner node['blossom']['user']
group node['blossom']['group']
mode '0640'
variables(
port: node['blossom']['port'],
host: node['blossom']['host'],
domain: node['blossom']['domain'],
user: node['blossom']['user'],
storage_backend: node['blossom']['storage']['backend'],
storage_local_dir: node['blossom']['storage']['local']['dir'],
storage_s3: node['blossom']['storage']['s3'],
allowed_pubkeys: node['blossom']['allowed_pubkeys']
)
notifies :restart, 'service[blossom]', :delayed
end
systemd_unit 'blossom.service' do
content({
Unit: {
Description: 'Blossom Server',
After: 'network.target'
},
Service: {
Type: 'simple',
User: node['blossom']['user'],
Group: node['blossom']['group'],
WorkingDirectory: node['blossom']['install_dir'],
ExecStart: '/usr/local/bin/deno task start config.yml',
Restart: 'on-failure',
Environment: [
"DENO_DIR=/home/#{node['blossom']['user']}/.cache/deno"
]
},
Install: {
WantedBy: 'multi-user.target'
}
})
action [:create]
end
service "blossom" do
action [:enable, :start]
end

View File

@@ -0,0 +1,43 @@
port: <%= @port %>
host: "<%= @host %>"
publicDomain: "<%= @domain %>"
database:
path: "/home/<%= @user %>/data/sqlite.db"
storage:
backend: "<%= @storage_backend %>"
<% if @storage_backend == 'local' %>
local:
dir: "<%= @storage_local_dir %>"
<% elsif @storage_backend == 's3' %>
s3:
endpoint: "<%= @storage_s3['endpoint'] %>"
region: "<%= @storage_s3['region'] %>"
bucket: "<%= @storage_s3['bucket'] %>"
accessKey: "<%= @storage_s3['access_key'] %>"
secretKey: "<%= @storage_s3['secret_key'] %>"
<% end %>
rules:
<% if @allowed_pubkeys && !@allowed_pubkeys.empty? %>
- type: "*"
expiration: "100 years"
pubkeys:
<% @allowed_pubkeys.each do |pk| %>
- "<%= pk %>"
<% end %>
<% else %>
- type: "image/*"
expiration: 1 month
- type: "video/*"
expiration: 1 week
- type: "*"
expiration: 1 week
<% end %>
upload:
enabled: true
requireAuth: <%= @allowed_pubkeys && !@allowed_pubkeys.empty? ? 'true' : 'false' %>
requirePubkeyInRule: <%= @allowed_pubkeys && !@allowed_pubkeys.empty? ? 'true' : 'false' %>
maxSize: 5368709120 # 5 GB