Skip to content

Deploying juntagrico

Introduction

juntagrico is a comprehensive, open-source management platform designed specifically for community-supported agriculture (CSA) cooperatives. Built with Django, it provides tools for managing members, subscriptions, work assignments, delivery locations, and financial operations that are essential for running a successful CSA farm.

The platform was created to address the unique challenges of CSA management, where members purchase shares of a farm’s harvest in advance and often contribute labor hours in exchange for reduced costs. juntagrico handles the complexity of subscription management, job scheduling, and member communication.

Key highlights of juntagrico:

  • Member Management: Track members, shares, and subscription types
  • Work Assignments: Schedule and track member labor contributions
  • Subscription Handling: Manage different subscription sizes and types
  • Delivery Locations: Organize pickup points and delivery schedules
  • Financial Tracking: Handle payments, billing, and financial reports
  • Email Integration: Built-in email system for member communication
  • Multi-Language Support: Available in German, English, French, and more
  • Customizable: Extensive configuration options for different CSA models
  • Role-Based Access: Different permission levels for members, coordinators, and admins
  • 100% Open Source: LGPL licensed with active community development

This guide walks through deploying juntagrico on Klutch.sh using Docker, configuring your CSA settings, and getting started with member management.

Why Deploy juntagrico on Klutch.sh

Deploying juntagrico on Klutch.sh provides several advantages for CSA cooperatives:

Simplified Deployment: Klutch.sh builds and deploys juntagrico without complex Django setup.

Persistent Storage: Member data, subscriptions, and configurations survive restarts.

HTTPS by Default: Secure access for members managing their accounts and payments.

GitHub Integration: Track configuration changes and automate deployments.

Scalable Resources: Handle growing membership with easy resource scaling.

Environment Variable Management: Store database credentials and email settings securely.

Custom Domains: Use your CSA’s domain for a professional member portal.

Always-On Availability: Members can access their accounts 24/7.

Prerequisites

Before deploying juntagrico on Klutch.sh, ensure you have:

  • A Klutch.sh account
  • A GitHub account with a repository for your configuration
  • Basic familiarity with Docker and Django applications
  • Email service credentials for member communication
  • (Optional) A custom domain for your CSA portal

Understanding juntagrico Architecture

juntagrico is built on Django with the following components:

Django Framework: The web application framework providing MVC structure, ORM, and admin interface.

PostgreSQL Database: Stores all member, subscription, and operational data.

Static Files: CSS, JavaScript, and images served through Django or a CDN.

Email Backend: Sends notifications, job reminders, and member communications.

Template System: Customizable HTML templates for the member portal.

Preparing Your Repository

Create a GitHub repository for your juntagrico deployment.

Repository Structure

juntagrico-deploy/
├── Dockerfile
├── juntagrico_app/
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── requirements.txt
├── README.md
└── .dockerignore

Creating the Dockerfile

Create a Dockerfile in the root of your repository:

FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV DJANGO_SETTINGS_MODULE=juntagrico_app.settings
# Install system dependencies
RUN apt-get update && apt-get install -y \
libpq-dev \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Collect static files
RUN python manage.py collectstatic --noinput || true
# Expose the application port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/')" || exit 1
# Run the application
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "juntagrico_app.wsgi:application"]

Creating requirements.txt

juntagrico>=1.6.0
gunicorn>=21.0.0
psycopg2-binary>=2.9.0
dj-database-url>=2.0.0
whitenoise>=6.0.0

Creating Django Settings

Create juntagrico_app/settings.py:

import os
import dj_database_url
from juntagrico.util.settings import *
# Basic Django settings
SECRET_KEY = os.environ.get('SECRET_KEY', 'change-me-in-production')
DEBUG = os.environ.get('DEBUG', 'False').lower() == 'true'
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '*').split(',')
# Database configuration
DATABASES = {
'default': dj_database_url.config(
default=os.environ.get('DATABASE_URL', 'sqlite:///db.sqlite3')
)
}
# Static files with WhiteNoise
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
MIDDLEWARE.insert(1, 'whitenoise.middleware.WhiteNoiseMiddleware')
# Email configuration
EMAIL_HOST = os.environ.get('EMAIL_HOST', 'localhost')
EMAIL_PORT = int(os.environ.get('EMAIL_PORT', 587))
EMAIL_USE_TLS = os.environ.get('EMAIL_USE_TLS', 'True').lower() == 'true'
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER', '')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD', '')
DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL', 'noreply@example.com')
# juntagrico settings
ORGANISATION_NAME = os.environ.get('ORGANISATION_NAME', 'My CSA Farm')
ORGANISATION_ADDRESS = {
'name': os.environ.get('ORG_NAME', 'My CSA Farm'),
'street': os.environ.get('ORG_STREET', '123 Farm Road'),
'city': os.environ.get('ORG_CITY', 'Farmville'),
'extra': os.environ.get('ORG_EXTRA', ''),
}
SHARE_PRICE = float(os.environ.get('SHARE_PRICE', '250'))
CURRENCY = os.environ.get('CURRENCY', 'USD')
BUSINESS_YEAR_START = {'day': 1, 'month': 1}
# Install juntagrico app
INSTALLED_APPS.insert(0, 'juntagrico')

Creating URL Configuration

Create juntagrico_app/urls.py:

from django.urls import path, include
urlpatterns = [
path('', include('juntagrico.urls')),
]

Creating WSGI Application

Create juntagrico_app/wsgi.py:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'juntagrico_app.settings')
application = get_wsgi_application()

Environment Variables Reference

VariableRequiredDefaultDescription
SECRET_KEYYes-Django secret key for cryptographic signing
DATABASE_URLYes-PostgreSQL connection URL
ALLOWED_HOSTSNo*Comma-separated list of allowed hostnames
DEBUGNoFalseEnable Django debug mode
EMAIL_HOSTYes-SMTP server hostname
EMAIL_PORTNo587SMTP server port
EMAIL_HOST_USERYes-SMTP username
EMAIL_HOST_PASSWORDYes-SMTP password
DEFAULT_FROM_EMAILYes-Sender email address
ORGANISATION_NAMENoMy CSA FarmYour CSA’s name
SHARE_PRICENo250Price per share
CURRENCYNoUSDCurrency code

Deploying juntagrico on Klutch.sh

    Generate a Secret Key

    Create a secure Django secret key:

    Terminal window
    python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"

    Set Up PostgreSQL Database

    Deploy a PostgreSQL database on Klutch.sh or use an external database service. Note the connection URL.

    Push Your Repository to GitHub

    Initialize and push your repository:

    Terminal window
    git init
    git add .
    git commit -m "Initial juntagrico deployment configuration"
    git remote add origin https://github.com/yourusername/juntagrico-deploy.git
    git push -u origin main

    Create a New Project on Klutch.sh

    Navigate to the Klutch.sh dashboard and create a new project named “juntagrico” or “csa-portal”.

    Create a New App

    Within your project, create a new app. Connect your GitHub account and select the repository containing your Dockerfile.

    Configure HTTP Traffic

    In the deployment settings:

    • Select HTTP as the traffic type
    • Set the internal port to 8000

    Set Environment Variables

    Add the following environment variables:

    VariableValue
    SECRET_KEYYour generated secret key
    DATABASE_URLpostgresql://user:pass@host:5432/juntagrico
    ALLOWED_HOSTSyour-app-name.klutch.sh
    EMAIL_HOSTYour SMTP server
    EMAIL_PORT587
    EMAIL_HOST_USERYour SMTP username
    EMAIL_HOST_PASSWORDYour SMTP password
    DEFAULT_FROM_EMAILnoreply@yourcsa.org
    ORGANISATION_NAMEYour CSA Name

    Attach Persistent Volumes

    Add a volume for uploaded files:

    Mount PathRecommended SizePurpose
    /app/media5 GBUser uploads and media files
    /app/staticfiles1 GBCollected static files

    Deploy Your Application

    Click Deploy to start the build process.

    Run Database Migrations

    After deployment, run migrations to set up the database:

    Terminal window
    python manage.py migrate
    python manage.py createsuperuser

    Access juntagrico

    Once deployed, access your CSA portal at https://your-app-name.klutch.sh.

Initial Configuration

Creating an Admin Account

Access the Django admin at /admin/ and log in with your superuser credentials.

Setting Up Subscription Types

Configure the subscription offerings for your CSA:

  1. Go to Subscription Types
  2. Add subscription sizes (e.g., Small, Medium, Large)
  3. Set prices and share requirements
  4. Configure pickup frequencies

Adding Delivery Locations

Set up pickup points for members:

  1. Go to Depots
  2. Add each pickup location with address and schedule
  3. Assign coordinators

Creating Jobs

Define work assignments for member participation:

  1. Go to Jobs
  2. Create job types (harvesting, packing, delivery)
  3. Set required participants and time slots

Managing Members

Member Registration

Members can self-register through the portal:

  1. New members sign up with email
  2. They select subscription type and size
  3. Choose delivery location
  4. Agree to terms and submit payment information

Assigning Shares

Admins can manage member subscriptions:

  1. View member profiles
  2. Adjust subscription sizes
  3. Manage payment status
  4. Track work hour contributions

Customization

Branding

Customize the portal appearance:

  • Override templates in your repository
  • Add custom CSS for your CSA’s branding
  • Upload logo and images

Email Templates

Customize notification emails:

  • Welcome messages
  • Job reminders
  • Payment notifications

Troubleshooting

Migration Errors

  • Ensure database credentials are correct
  • Check for conflicting migrations
  • Run python manage.py migrate --run-syncdb

Email Not Sending

  • Verify SMTP credentials
  • Check email service limits
  • Review Django email logs

Static Files Missing

  • Run collectstatic command
  • Check WhiteNoise configuration
  • Verify static file URLs

Additional Resources

Conclusion

Deploying juntagrico on Klutch.sh gives your CSA cooperative a professional, reliable platform for managing members, subscriptions, and farm operations. With persistent storage for member data and secure HTTPS access, you can focus on growing food and building community rather than managing IT infrastructure.

Whether you’re running a small neighborhood farm share or a large regional CSA, juntagrico on Klutch.sh provides the tools you need for successful community-supported agriculture.