Claude super rough first cut of a few packages. Almost certainly entirely unusable...

This commit is contained in:
2025-07-07 17:20:00 -05:00
parent c315498391
commit b0ca0ef49c
135 changed files with 0 additions and 183 deletions

View File

@@ -0,0 +1,44 @@
{
"id": "net.consuldemocracy.cloudron",
"title": "Consul Democracy",
"author": "Consul Democracy Community",
"description": "Open Government and E-Participation Web Software",
"tagline": "The most comprehensive citizen participation platform",
"version": "1.0.0",
"healthCheckPath": "/",
"httpPort": 8000,
"addons": {
"localstorage": {},
"postgresql": {
"version": "14"
},
"ldap": {},
"sendmail": {}
},
"manifestVersion": 2,
"website": "https://consuldemocracy.org",
"contactEmail": "info@consuldemocracy.org",
"icon": "file://logo.png",
"tags": [
"democracy",
"participation",
"open-government",
"rails"
],
"dockerImage": "{origin}/consuldemocracy",
"memoryLimit": 1024,
"documentationUrl": "https://docs.consuldemocracy.org/",
"forumUrl": "https://github.com/consuldemocracy/consuldemocracy/discussions",
"minBoxVersion": "7.0.0",
"mediaLinks": [],
"changelog": "Initial version",
"postInstallMessage": "Consul Democracy has been successfully installed! The default administrator credentials are:\n\nUsername: admin@example.org\nPassword: password\n\nPlease login and change these immediately.",
"configurePath": "/admin",
"backup": {
"backupScriptPath": "/app/code/backup.sh"
},
"sso": {
"loginPath": "/users/sign_in",
"callbackPath": "/oauth/callback"
}
}

View File

@@ -0,0 +1,114 @@
# Consul Democracy - Cloudron Build Notes
## Overview
Consul Democracy is an open-source citizen participation and open government platform, originally developed for the Madrid City government. This package enables easy deployment on the Cloudron platform with full integration of Cloudrons authentication, database, and email systems.
## Prerequisites
- A running Cloudron instance (version 7.0.0 or later)
- Basic familiarity with Cloudrons CLI for package development
- Git installed on your local machine
## Building the Package
1. Clone this repository:
```bash
git clone https://github.com/your-username/cloudron-consuldemocracy.git
cd cloudron-consuldemocracy
```
2. Install the Cloudron CLI if you havent already:
```bash
npm install -g cloudron
```
3. Login to your Cloudron:
```bash
cloudron login https://my.example.com
```
4. Build and install the package:
```bash
cloudron build
cloudron install —image consuldemocracy
```
## Configuration
### Post-Installation
After installation, the app will be available at your configured domain. The initial admin credentials are:
- Username: admin@example.org
- Password: password
**Important:** Change these credentials immediately after logging in.
### LDAP Integration
The package is configured to use Cloudrons LDAP server for authentication. Users who have access to the app through Cloudrons access control panel will be able to log in using their Cloudron credentials.
### OIDC Integration
For enhanced security, the package also supports Cloudrons OIDC provider. This is automatically configured during installation.
### Email Configuration
The package is configured to use Cloudrons SMTP server for sending emails. No additional configuration is needed.
## Customization
### Environment Variables
You can customize the app by setting environment variables in the Cloudron app configuration:
- `CONSUL_CUSTOM_LOGO`: URL to a custom logo
- `CONSUL_ORGANIZATION_NAME`: Name of your organization
- `CONSUL_THEME_COLOR`: Primary theme color (hex code)
### Filesystem Structure
- `/app/data/files`: Persistent storage for uploaded files
- `/app/data/images`: Persistent storage for uploaded images
- `/app/data/log`: Application logs
- `/app/data/tmp`: Temporary files
## Troubleshooting
### Common Issues
1. **Database Migration Errors**:
Check the app logs for specific error messages:
```bash
cloudron logs -f
```
2. **Authentication Issues**:
Ensure that the LDAP configuration is correct and that users have been granted access to the app in Cloudrons access control panel.
3. **Email Delivery Problems**:
Verify that the Cloudron mail addon is properly configured.
### Support
For issues specific to this package:
- Create an issue in the GitHub repository
- Contact the maintainer at: your-email@example.com
For issues with Consul Democracy itself:
- Visit the [Consul Democracy documentation](https://docs.consuldemocracy.org/)
- Check the [GitHub issues](https://github.com/consuldemocracy/consuldemocracy/issues)
## Updates and Maintenance
To update the app:
1. Pull the latest changes from the repository
2. Rebuild the package:
```bash
cloudron build
cloudron update —app consuldemocracy
```
Regular database backups are automatically handled by Cloudrons backup system.

View File

@@ -0,0 +1,93 @@
FROM cloudron/base:4.2.0
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
pkg-config \
git \
curl \
ruby-full \
nodejs \
npm \
imagemagick \
libpq-dev \
libxml2-dev \
libxslt1-dev \
zlib1g-dev \
libyaml-dev \
libssl-dev \
libreadline-dev \
supervisor \
nginx \
&& rm -rf /var/lib/apt/lists/*
# Update npm and install yarn
RUN npm install -g yarn
# Set Ruby and NodeJS versions
ENV RUBY_VERSION=3.2.8
ENV NODE_VERSION=18.20.3
# Ensure correct nodejs version (Node.js is already installed in base image)
RUN n ${NODE_VERSION}
# Create app directory structure
RUN mkdir -p /app/code /app/data /tmp/data
# Clone the app
RUN git clone https://github.com/consuldemocracy/consuldemocracy.git /app/code
WORKDIR /app/code
# Install bundler
RUN gem install bundler
# Install gems
RUN bundle install --deployment --without development test
# Install JavaScript dependencies
RUN yarn install
# Precompile assets
RUN SECRET_KEY_BASE=precompilation_key RAILS_ENV=production bundle exec rake assets:precompile
# Configure Nginx
RUN rm -f /etc/nginx/sites-enabled/default
COPY nginx.conf /etc/nginx/sites-enabled/consuldemocracy.conf
# Configure Supervisor
COPY supervisord.conf /etc/supervisor/conf.d/consuldemocracy.conf
# Add initialization script for /app/data
COPY init-data.sh /app/code/
RUN chmod +x /app/code/init-data.sh
# Copy backup script
COPY backup.sh /app/code/
RUN chmod +x /app/code/backup.sh
# Copy database configuration
COPY database.yml /app/code/config/database.yml
# Copy secrets configuration template
COPY secrets.yml /app/code/config/secrets.yml
# Add LDAP configuration
COPY ldap.yml /app/code/config/ldap.yml
# Copy oauth integration config
COPY oauth.rb /app/code/config/initializers/oauth.rb
# Copy the startup script
COPY start.sh /app/code/
RUN chmod +x /app/code/start.sh
# Set appropriate permissions
RUN chown -R cloudron:cloudron /app/code
# Configure app for production
ENV RAILS_ENV=production
ENV RAILS_SERVE_STATIC_FILES=true
# Entrypoint
CMD ["/app/code/start.sh"]

View File

@@ -0,0 +1,23 @@
#!/bin/bash
set -e
echo "Performing Consul Democracy backup..."
# The Cloudron backup system will automatically handle:
# 1. /app/data
# 2. PostgreSQL database
# We don't need any custom backup logic as Cloudron handles
# both the database and the data directory.
# In case of any application-specific backup needs:
# 1. Run any pre-backup tasks
cd /app/code
RAILS_ENV=production bundle exec rake tmp:clear
# 2. Ensure all user uploads are synced
sync
echo "Backup preparation complete"
exit 0

View File

@@ -0,0 +1,18 @@
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: consuldemocracy_development
test:
<<: *default
database: consuldemocracy_test
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 20 } %>

View File

@@ -0,0 +1,39 @@
#!/bin/bash
set -e
echo "Initializing data directory..."
# Check if data directories exist, if not create them
mkdir -p /app/data/files
mkdir -p /app/data/images
mkdir -p /app/data/log
mkdir -p /app/data/tmp
# Generate a secret key base if it doesn't exist
if [ ! -f /app/data/secret_key_base ]; then
echo "Generating secret key base..."
openssl rand -hex 64 > /app/data/secret_key_base
chmod 600 /app/data/secret_key_base
fi
# Create symlinks from app to data directory
if [ ! -L /app/code/storage ]; then
ln -sf /app/data/files /app/code/storage
fi
if [ ! -L /app/code/public/uploads ]; then
ln -sf /app/data/images /app/code/public/uploads
fi
if [ ! -L /app/code/log ]; then
ln -sf /app/data/log /app/code/log
fi
if [ ! -L /app/code/tmp ]; then
ln -sf /app/data/tmp /app/code/tmp
fi
# Set proper permissions
chown -R cloudron:cloudron /app/data
echo "Data directory initialized."

View File

@@ -0,0 +1,15 @@
production:
enabled: true
host: <%= ENV['LDAP_HOST'] %>
port: <%= ENV['LDAP_PORT'] %>
ssl: true
admin_user: <%= ENV['LDAP_ADMIN_USER'] %>
admin_password: <%= ENV['LDAP_ADMIN_PASSWORD'] %>
base: <%= ENV['LDAP_BASE'] %>
user_filter: "(uid=%{username})"
group_base: <%= ENV['CLOUDRON_LDAP_GROUPS_BASE_DN'] %>
required_groups:
- <%= ENV['CLOUDRON_LDAP_GROUPS_BASE_DN'] %>
attribute_mapping:
email: mail
name: displayName

View File

@@ -0,0 +1,47 @@
server {
listen 8000;
server_name _;
root /app/code/public;
client_max_body_size 100M;
# Handle asset requests
location ~ ^/(assets|packs)/ {
expires max;
add_header Cache-Control public;
}
# Proxy requests to the Rails application
location / {
try_files $uri @passenger;
}
location @passenger {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Port $server_port;
# Forward the original request scheme (http or https)
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
# Needed for Cloudron authentication
proxy_set_header X-Cloudron-Proxy-Port 8000;
# Proxy to the Rails application served by Puma
proxy_pass http://unix:/run/consuldemocracy.sock;
proxy_redirect off;
}
# Error pages
error_page 500 502 503 504 /500.html;
error_page 404 /404.html;
error_page 422 /422.html;
# Logging
access_log /dev/stdout;
error_log /dev/stderr;
}

View File

@@ -0,0 +1,29 @@
# Configure OAuth integration with Cloudron
if ENV['CLOUDRON_OIDC_IDENTIFIER'] && Rails.env.production?
Rails.application.config.middleware.use OmniAuth::Builder do
provider :openid_connect, {
name: :cloudron,
scope: [:openid, :email, :profile],
response_type: :code,
uid_field: 'sub',
discovery: true,
client_options: {
identifier: ENV['CLOUDRON_OIDC_CLIENT_ID'],
secret: ENV['CLOUDRON_OIDC_CLIENT_SECRET'],
redirect_uri: "https://#{ENV['CLOUDRON_APP_DOMAIN']}/oauth/callback",
port: 443,
scheme: 'https',
host: "#{ENV['CLOUDRON_APP_DOMAIN']}",
discovery_document: ENV['CLOUDRON_OIDC_IDENTIFIER']
},
client_auth_method: 'secret_basic'
}
end
# Map additional user attributes from Cloudron OIDC
OmniAuth::Strategies::OAuth2.class_eval do
def callback_url
full_host + script_name + callback_path
end
end
end

View File

@@ -0,0 +1,21 @@
default: &default
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
server_name: <%= ENV["CLOUDRON_APP_DOMAIN"] %>
smtp_settings:
address: <%= ENV["SMTP_ADDRESS"] %>
port: <%= ENV["SMTP_PORT"] %>
domain: <%= ENV["SMTP_DOMAIN"] %>
user_name: <%= ENV["SMTP_USER_NAME"] %>
password: <%= ENV["SMTP_PASSWORD"] %>
authentication: "login"
enable_starttls_auto: true
mailer_sender: <%= "noreply@#{ENV['CLOUDRON_APP_DOMAIN']}" %>
development:
<<: *default
test:
<<: *default
production:
<<: *default

View File

@@ -0,0 +1,45 @@
#!/bin/bash
set -e
echo "Starting Consul Democracy..."
# Initialize the data directory if it doesn't exist
/app/code/init-data.sh
cd /app/code
# Setup environment variables
export DATABASE_URL="postgresql://${CLOUDRON_POSTGRESQL_USERNAME}:${CLOUDRON_POSTGRESQL_PASSWORD}@${CLOUDRON_POSTGRESQL_HOST}:${CLOUDRON_POSTGRESQL_PORT}/${CLOUDRON_POSTGRESQL_DATABASE}"
export SECRET_KEY_BASE=$(cat /app/data/secret_key_base)
export RAILS_ENV=production
export RAILS_SERVE_STATIC_FILES=true
export RAILS_LOG_TO_STDOUT=true
# Configure email settings
export SMTP_ADDRESS=${CLOUDRON_MAIL_SMTP_SERVER}
export SMTP_PORT=${CLOUDRON_MAIL_SMTP_PORT}
export SMTP_DOMAIN=${CLOUDRON_APP_DOMAIN}
export SMTP_USER_NAME=${CLOUDRON_MAIL_SMTP_USERNAME}
export SMTP_PASSWORD=${CLOUDRON_MAIL_SMTP_PASSWORD}
# LDAP Setup for Cloudron integration
export LDAP_HOST=${CLOUDRON_LDAP_SERVER}
export LDAP_PORT=${CLOUDRON_LDAP_PORT}
export LDAP_ADMIN_USER=${CLOUDRON_LDAP_BIND_DN}
export LDAP_ADMIN_PASSWORD=${CLOUDRON_LDAP_BIND_PASSWORD}
export LDAP_BASE=${CLOUDRON_LDAP_USERS_BASE_DN}
# Run db migrations if needed
echo "Running database migrations..."
bundle exec rake db:migrate
# Seed the database if it's the first run
if [ ! -f /app/data/.initialized ]; then
echo "First run detected, seeding the database..."
bundle exec rake db:seed
touch /app/data/.initialized
fi
# Start the application server via supervisord
echo "Starting supervisord..."
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf

View File

@@ -0,0 +1,32 @@
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:rails]
directory=/app/code
command=bundle exec puma -e production -b unix:///run/consuldemocracy.sock
user=cloudron
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
environment=RAILS_ENV=production,RAILS_LOG_TO_STDOUT=true,RAILS_SERVE_STATIC_FILES=true
[program:sidekiq]
directory=/app/code
command=bundle exec sidekiq -e production
user=cloudron
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
environment=RAILS_ENV=production,RAILS_LOG_TO_STDOUT=true