From 34990a9162ce9623a0310ed60d8b8ad4e50c61cb Mon Sep 17 00:00:00 2001 From: Charles N Wyble Date: Mon, 21 Apr 2025 14:18:31 -0400 Subject: [PATCH] first cut of elabftw --- .../CloudronManifest.json | 30 +++++ Techops/elabftw.knownelement.com/Dockerfile | 59 ++++++++++ .../docker-compose.yml | 1 - .../elabftw-BuildNotes.md | 109 ++++++++++++++++++ .../elabftw.knownelement.com/input-files/info | 1 - Techops/elabftw.knownelement.com/nginx.conf | 38 ++++++ .../output-files/info | 1 - Techops/elabftw.knownelement.com/start.sh | 53 +++++++++ .../elabftw.knownelement.com/supervisord.conf | 24 ++++ .../vendor-files/info | 1 - 10 files changed, 313 insertions(+), 4 deletions(-) create mode 100644 Techops/elabftw.knownelement.com/CloudronManifest.json create mode 100644 Techops/elabftw.knownelement.com/Dockerfile delete mode 100644 Techops/elabftw.knownelement.com/docker-compose.yml create mode 100644 Techops/elabftw.knownelement.com/elabftw-BuildNotes.md delete mode 100644 Techops/elabftw.knownelement.com/input-files/info create mode 100644 Techops/elabftw.knownelement.com/nginx.conf delete mode 100644 Techops/elabftw.knownelement.com/output-files/info create mode 100644 Techops/elabftw.knownelement.com/start.sh create mode 100644 Techops/elabftw.knownelement.com/supervisord.conf delete mode 100644 Techops/elabftw.knownelement.com/vendor-files/info diff --git a/Techops/elabftw.knownelement.com/CloudronManifest.json b/Techops/elabftw.knownelement.com/CloudronManifest.json new file mode 100644 index 0000000..b0fa1bf --- /dev/null +++ b/Techops/elabftw.knownelement.com/CloudronManifest.json @@ -0,0 +1,30 @@ +{ + "id": "org.elabftw.cloudron", + "title": "eLabFTW", + "author": "Nicolas CARPi", + "description": "Electronic laboratory notebook to track experiments, manage protocols, store laboratory inventory, communicate with others and more. Your best lab companion.", + "tagline": "Electronic lab notebook for researchers", + "version": "1.0.0", + "healthCheckPath": "/", + "httpPort": 8000, + "addons": { + "mysql": {}, + "localstorage": {} + }, + "manifestVersion": 2, + "website": "https://www.elabftw.net", + "contactEmail": "support@example.com", + "icon": "file://logo.png", + "memoryLimit": 1024, + "tags": ["science", "lab", "research", "notebook", "eln"], + "minBoxVersion": "7.4.0", + "postInstallMessage": "eLabFTW has been successfully installed! You will need to create a Sysadmin account when you first access the application.", + "documentationUrl": "https://doc.elabftw.net/", + "forwardedHeaders": ["X-Forwarded-For", "X-Forwarded-Proto", "X-Forwarded-Host"], + "tcpPorts": {}, + "optionalSso": { + "ldap": { + "enabled": true + } + } +} \ No newline at end of file diff --git a/Techops/elabftw.knownelement.com/Dockerfile b/Techops/elabftw.knownelement.com/Dockerfile new file mode 100644 index 0000000..2e35881 --- /dev/null +++ b/Techops/elabftw.knownelement.com/Dockerfile @@ -0,0 +1,59 @@ +FROM cloudron/base:4.2.0 + +# Install required packages +RUN apt-get update && \ + apt-get install -y \ + php-cli \ + php-fpm \ + php-mysql \ + php-curl \ + php-gd \ + php-intl \ + php-mbstring \ + php-xml \ + php-zip \ + php-bcmath \ + nginx \ + supervisor \ + curl \ + zip \ + unzip \ + git \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install Composer +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +# Get the latest eLabFTW release +WORKDIR /app/code +RUN git clone https://github.com/elabftw/elabftw.git . && \ + composer install --no-dev --optimize-autoloader + +# Configure NGINX +COPY nginx.conf /etc/nginx/sites-available/default + +# Prepare directory structure +RUN mkdir -p /app/data/uploads /app/data/config /app/data/logs /run/php && \ + chown -R cloudron:cloudron /app/data /run/php + +# Copy initialization data +RUN mkdir -p /tmp/data/config /tmp/data/uploads /tmp/data/logs && \ + cp -r /app/code/config-example.yml /tmp/data/config/config.yml && \ + chown -R cloudron:cloudron /tmp/data + +# Copy start script and supervisor config +COPY start.sh /app/code/ +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf +RUN chmod +x /app/code/start.sh + +# Configure PHP-FPM +RUN sed -i 's/www-data/cloudron/g' /etc/php/*/fpm/pool.d/www.conf && \ + sed -i 's/listen = \/run\/php\/php[0-9]\.[0-9]-fpm.sock/listen = \/run\/php\/php-fpm.sock/g' /etc/php/*/fpm/pool.d/www.conf && \ + echo 'catch_workers_output = yes' >> /etc/php/*/fpm/pool.d/www.conf + +# Create logo image +RUN curl -o /app/code/logo.png https://raw.githubusercontent.com/elabftw/elabftw/master/src/ts/img/logo.png + +WORKDIR /app/code + +CMD ["/app/code/start.sh"] \ No newline at end of file diff --git a/Techops/elabftw.knownelement.com/docker-compose.yml b/Techops/elabftw.knownelement.com/docker-compose.yml deleted file mode 100644 index f3d7458..0000000 --- a/Techops/elabftw.knownelement.com/docker-compose.yml +++ /dev/null @@ -1 +0,0 @@ -#elabftw docker compose for tsys \ No newline at end of file diff --git a/Techops/elabftw.knownelement.com/elabftw-BuildNotes.md b/Techops/elabftw.knownelement.com/elabftw-BuildNotes.md new file mode 100644 index 0000000..adf73a8 --- /dev/null +++ b/Techops/elabftw.knownelement.com/elabftw-BuildNotes.md @@ -0,0 +1,109 @@ +# eLabFTW Cloudron Package Build Notes + +This document provides instructions for building, testing, and deploying the eLabFTW Cloudron package. + +## Package Overview + +This package deploys eLabFTW, an open-source electronic laboratory notebook (ELN) for researchers, on Cloudron. The package: + +- Uses the MySQL addon for database storage +- Uses the localstorage addon for file storage +- Includes NGINX and PHP-FPM configuration +- Supports optional LDAP authentication through Cloudron + +## Building the Package + +1. Create a new directory for your package: + ```bash + mkdir elabftw-cloudron + cd elabftw-cloudron + ``` + +2. Save all the provided files to this directory: + - CloudronManifest.json + - Dockerfile + - start.sh + - nginx.conf + - supervisord.conf + +3. Make the start.sh file executable: + ```bash + chmod +x start.sh + ``` + +4. Download the eLabFTW logo for the package icon: + ```bash + curl -o logo.png https://raw.githubusercontent.com/elabftw/elabftw/master/src/ts/img/logo.png + ``` + +5. Build the package: + ```bash + cloudron build + ``` + +## Testing the Package + +1. Install the package on your Cloudron for testing: + ```bash + cloudron install —location elabftw.example.com + ``` + +2. After installation, visit the application URL and complete the initial setup: + - Create the Sysadmin account + - Configure your teams and user groups + - Set up any initial templates or protocols + +3. Test the following functionality: + - User authentication (local accounts) + - File uploads (should be stored in /app/data/uploads) + - Database connection (should be using Cloudron MySQL) + - LDAP authentication (if enabled) + - General application functionality + +## Deploying to Production + +1. Once testing is complete, you can deploy to production: + ```bash + cloudron install —location elabftw.yourdomain.com + ``` + +2. For production use, consider: + - Setting up regular backups of the Cloudron app + - Configuring LDAP authentication if needed (via Cloudron UI) + - Adjusting memory limits in CloudronManifest.json if necessary based on usage + +## Post-Installation + +After installation, you’ll need to: + +1. Create a Sysadmin account when first accessing the application +2. Configure teams and user groups +3. Set up experiment templates and protocols as needed +4. Consider enabling and configuring LDAP authentication for easier user management + +## Troubleshooting + +- Check logs with `cloudron logs -f elabftw` +- If database issues occur, verify the MySQL addon is properly configured +- For file storage issues, check permissions on /app/data directories +- For authentication issues, verify LDAP configuration (if using LDAP) + +## Updates + +When a new version of eLabFTW is released: + +1. Update the git clone command in the Dockerfile to point to the latest release (or specific tag) +2. Rebuild and update your package: + ```bash + cloudron build + cloudron update —app elabftw.yourdomain.com + ``` + +## Customization + +You can customize the package by: + +1. Modifying the config.yml template in /tmp/data/config to set default values +2. Adjusting PHP settings in the Dockerfile or php.ini +3. Modifying NGINX configuration for special requirements +4. Adjusting memory limits in CloudronManifest.json based on usage patterns \ No newline at end of file diff --git a/Techops/elabftw.knownelement.com/input-files/info b/Techops/elabftw.knownelement.com/input-files/info deleted file mode 100644 index bc15867..0000000 --- a/Techops/elabftw.knownelement.com/input-files/info +++ /dev/null @@ -1 +0,0 @@ -This directory contains template files for the application at FQDN indidicated by the parent directory. They will be processed using mo (bash mustache). diff --git a/Techops/elabftw.knownelement.com/nginx.conf b/Techops/elabftw.knownelement.com/nginx.conf new file mode 100644 index 0000000..66094fe --- /dev/null +++ b/Techops/elabftw.knownelement.com/nginx.conf @@ -0,0 +1,38 @@ +server { + listen 8000; + server_name _; + root /app/code/web; + index index.php; + + client_max_body_size 100M; + + access_log /dev/stdout; + error_log /dev/stderr; + + location / { + try_files $uri /index.php$is_args$args; + } + + location ~ ^/index\.php(/|$) { + fastcgi_pass unix:/run/php/php-fpm.sock; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param HTTPS on; + + # Forward Cloudron proxy headers + fastcgi_param HTTP_X_FORWARDED_FOR $http_x_forwarded_for; + fastcgi_param HTTP_X_FORWARDED_PROTO $http_x_forwarded_proto; + fastcgi_param HTTP_X_FORWARDED_HOST $http_x_forwarded_host; + } + + # Deny access to other PHP files + location ~ \.php$ { + return 404; + } + + # Rewrite app routes + location @rewriteapp { + rewrite ^(.*)$ /index.php/$1 last; + } +} \ No newline at end of file diff --git a/Techops/elabftw.knownelement.com/output-files/info b/Techops/elabftw.knownelement.com/output-files/info deleted file mode 100644 index fe6b01e..0000000 --- a/Techops/elabftw.knownelement.com/output-files/info +++ /dev/null @@ -1 +0,0 @@ -This directory contains final docker compose files for the application at FQDN indidicated by the parent directory. diff --git a/Techops/elabftw.knownelement.com/start.sh b/Techops/elabftw.knownelement.com/start.sh new file mode 100644 index 0000000..ebf24bc --- /dev/null +++ b/Techops/elabftw.knownelement.com/start.sh @@ -0,0 +1,53 @@ +#!/bin/bash +set -e + +# Create directory structure if it doesn't exist +if [ ! -d /app/data/uploads ]; then + mkdir -p /app/data/uploads + cp -r /tmp/data/uploads/* /app/data/uploads/ 2>/dev/null || true + chown -R cloudron:cloudron /app/data/uploads +fi + +if [ ! -d /app/data/logs ]; then + mkdir -p /app/data/logs + cp -r /tmp/data/logs/* /app/data/logs/ 2>/dev/null || true + chown -R cloudron:cloudron /app/data/logs +fi + +if [ ! -f /app/data/config/config.yml ]; then + mkdir -p /app/data/config + cp -r /tmp/data/config/* /app/data/config/ 2>/dev/null || true + + # Configure database connection + sed -i "s/host: .*/host: ${CLOUDRON_MYSQL_HOST}/" /app/data/config/config.yml + sed -i "s/port: .*/port: ${CLOUDRON_MYSQL_PORT}/" /app/data/config/config.yml + sed -i "s/database: .*/database: ${CLOUDRON_MYSQL_DATABASE}/" /app/data/config/config.yml + sed -i "s/username: .*/username: ${CLOUDRON_MYSQL_USERNAME}/" /app/data/config/config.yml + sed -i "s/password: .*/password: ${CLOUDRON_MYSQL_PASSWORD}/" /app/data/config/config.yml + + # Configure paths + sed -i "s|uploads: .*|uploads: /app/data/uploads|" /app/data/config/config.yml + sed -i "s|logs: .*|logs: /app/data/logs|" /app/data/config/config.yml + + # Configure LDAP if enabled + if [ "${CLOUDRON_LDAP_ENABLED}" == "true" ]; then + # Update LDAP settings in config + sed -i "s/ldap_enabled: .*/ldap_enabled: true/" /app/data/config/config.yml + sed -i "s/ldap_host: .*/ldap_host: ${CLOUDRON_LDAP_SERVER}/" /app/data/config/config.yml + sed -i "s/ldap_port: .*/ldap_port: ${CLOUDRON_LDAP_PORT}/" /app/data/config/config.yml + sed -i "s/ldap_username: .*/ldap_username: ${CLOUDRON_LDAP_BIND_DN}/" /app/data/config/config.yml + sed -i "s/ldap_password: .*/ldap_password: ${CLOUDRON_LDAP_BIND_PASSWORD}/" /app/data/config/config.yml + sed -i "s/ldap_base_dn: .*/ldap_base_dn: ${CLOUDRON_LDAP_USERS_BASE_DN}/" /app/data/config/config.yml + fi + + chown -R cloudron:cloudron /app/data/config +fi + +# Create a symlink to the config file +ln -sf /app/data/config/config.yml /app/code/config.yml + +# Set proper permissions +chown -R cloudron:cloudron /app/data + +# Start the supervisord +exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf \ No newline at end of file diff --git a/Techops/elabftw.knownelement.com/supervisord.conf b/Techops/elabftw.knownelement.com/supervisord.conf new file mode 100644 index 0000000..3fc76b8 --- /dev/null +++ b/Techops/elabftw.knownelement.com/supervisord.conf @@ -0,0 +1,24 @@ +[supervisord] +nodaemon=true +logfile=/dev/stdout +logfile_maxbytes=0 + +[program:nginx] +command=/usr/sbin/nginx -g "daemon off;" +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autostart=true +autorestart=true +priority=10 + +[program:php-fpm] +command=/usr/sbin/php-fpm8.1 -F +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autostart=true +autorestart=true +priority=5 \ No newline at end of file diff --git a/Techops/elabftw.knownelement.com/vendor-files/info b/Techops/elabftw.knownelement.com/vendor-files/info deleted file mode 100644 index 110d921..0000000 --- a/Techops/elabftw.knownelement.com/vendor-files/info +++ /dev/null @@ -1 +0,0 @@ -This directory contains files from the vendor unmodified. They serve as a base for the input-files sibling directory