chore: add Cloudron PackageTemplate, helper script; add .gitattributes/.editorconfig; refine .gitignore; improve workspace scripts
This commit is contained in:
11
CloudronPackages/PackageTemplate/.dockerignore
Normal file
11
CloudronPackages/PackageTemplate/.dockerignore
Normal file
@@ -0,0 +1,11 @@
|
||||
# Ignore typical build context clutter
|
||||
.git
|
||||
.gitignore
|
||||
node_modules
|
||||
npm-debug.log
|
||||
*.log
|
||||
dist
|
||||
build
|
||||
Dockerfile.*
|
||||
.DS_Store
|
||||
|
19
CloudronPackages/PackageTemplate/CloudronManifest.json
Normal file
19
CloudronPackages/PackageTemplate/CloudronManifest.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"manifestVersion": 2,
|
||||
"id": "__APP_ID__",
|
||||
"title": "__APP_TITLE__",
|
||||
"author": "KNEL",
|
||||
"description": "Cloudron packaging template for __APP_TITLE__",
|
||||
"website": "https://example.com",
|
||||
"contactEmail": "admin@example.com",
|
||||
"version": "0.1.0",
|
||||
"changelog": "Initial package template",
|
||||
"healthCheckPath": "/",
|
||||
"httpPort": __HTTP_PORT__,
|
||||
"addons": {
|
||||
"localstorage": {}
|
||||
},
|
||||
"tags": ["template", "example"],
|
||||
"icon": "logo.png"
|
||||
}
|
||||
|
39
CloudronPackages/PackageTemplate/Dockerfile
Normal file
39
CloudronPackages/PackageTemplate/Dockerfile
Normal file
@@ -0,0 +1,39 @@
|
||||
FROM cloudron/base:4.2.0
|
||||
|
||||
# Metadata labels (edit as needed)
|
||||
LABEL org.opencontainers.image.title="__APP_TITLE__"
|
||||
LABEL org.opencontainers.image.description="Cloudron package for __APP_TITLE__"
|
||||
LABEL org.opencontainers.image.source="https://example.com"
|
||||
|
||||
# Install OS dependencies here as needed
|
||||
# RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
# curl ca-certificates tini \
|
||||
# && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# App code lives in /app/code (read-only at runtime)
|
||||
WORKDIR /app/code
|
||||
|
||||
# Copy application code (adjust as needed)
|
||||
# COPY . /app/code
|
||||
|
||||
# Create persistent directory for application data
|
||||
RUN mkdir -p /app/data && chown -R cloudron:cloudron /app/data
|
||||
|
||||
# Copy startup script
|
||||
COPY start.sh /app/pkg/start.sh
|
||||
RUN chmod +x /app/pkg/start.sh && chown cloudron:cloudron /app/pkg/start.sh
|
||||
|
||||
USER cloudron
|
||||
|
||||
# Expose the app port specified in manifest
|
||||
EXPOSE __HTTP_PORT__
|
||||
|
||||
# Default environment (customize per app)
|
||||
ENV NODE_ENV=production \
|
||||
APP_PORT=__HTTP_PORT__
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
||||
CMD curl -fsS http://127.0.0.1:${APP_PORT}/ || exit 1
|
||||
|
||||
CMD ["/app/pkg/start.sh"]
|
||||
|
24
CloudronPackages/PackageTemplate/README.md
Normal file
24
CloudronPackages/PackageTemplate/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# Package Template for Cloudron Apps
|
||||
|
||||
This is a minimal template to package an application for Cloudron.
|
||||
|
||||
Replace placeholders in files with your app specifics:
|
||||
- `__APP_ID__` (e.g., com.example.myapp)
|
||||
- `__APP_TITLE__` (human name)
|
||||
- `__HTTP_PORT__` (default internal app port)
|
||||
|
||||
Files
|
||||
- `CloudronManifest.json` – base manifest
|
||||
- `Dockerfile` – uses cloudron/base, non-root user, healthcheck
|
||||
- `start.sh` – startup script with addon detection examples
|
||||
- `nginx.conf` (optional) – example reverse proxy
|
||||
- `supervisord.conf` (optional) – process manager example
|
||||
- `config.yaml` (optional) – sample app config
|
||||
- `logo.png` – add your 512x512 PNG icon here (not provided in template)
|
||||
|
||||
Usage
|
||||
1. Create a new package from this template using `scripts/new-package.sh`:
|
||||
`scripts/new-package.sh MyApp --id com.example.myapp --title "My App" --port 3000`
|
||||
2. Adjust Dockerfile and start.sh to run your app.
|
||||
3. Build and test locally; then commit and push.
|
||||
|
11
CloudronPackages/PackageTemplate/config.yaml
Normal file
11
CloudronPackages/PackageTemplate/config.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
# Example configuration template for __APP_TITLE__
|
||||
server:
|
||||
port: __HTTP_PORT__
|
||||
|
||||
data:
|
||||
dir: /app/data
|
||||
|
||||
database:
|
||||
# url: ${CLOUDRON_POSTGRESQL_URL}
|
||||
# redis: ${CLOUDRON_REDIS_URL}
|
||||
|
26
CloudronPackages/PackageTemplate/nginx.conf
Normal file
26
CloudronPackages/PackageTemplate/nginx.conf
Normal file
@@ -0,0 +1,26 @@
|
||||
user cloudron;
|
||||
worker_processes auto;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
events { worker_connections 1024; }
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
access_log /var/log/nginx/access.log main;
|
||||
sendfile on;
|
||||
|
||||
server {
|
||||
listen __HTTP_PORT__;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass http://127.0.0.1:__HTTP_PORT__;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
39
CloudronPackages/PackageTemplate/start.sh
Normal file
39
CloudronPackages/PackageTemplate/start.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
log() { echo "[start] $(date -Is) $*"; }
|
||||
abort() { echo "[start] ERROR: $*" >&2; exit 1; }
|
||||
|
||||
# Defaults
|
||||
: "${APP_PORT:=__HTTP_PORT__}"
|
||||
|
||||
log "Starting __APP_TITLE__ on port ${APP_PORT}"
|
||||
|
||||
# Example: ensure /app/data exists and is writable
|
||||
mkdir -p /app/data
|
||||
chown -R cloudron:cloudron /app/data || true
|
||||
|
||||
# Example addon integration (uncomment and adapt as needed)
|
||||
# if [[ -n "${CLOUDRON_POSTGRESQL_URL:-}" ]]; then
|
||||
# log "Detected PostgreSQL addon"
|
||||
# # Use $CLOUDRON_POSTGRESQL_* env vars
|
||||
# fi
|
||||
|
||||
# if [[ -n "${CLOUDRON_REDIS_URL:-}" ]]; then
|
||||
# log "Detected Redis addon"
|
||||
# fi
|
||||
|
||||
# If your app needs config generation, do it here
|
||||
# cat > /app/data/config.yaml <<'YAML'
|
||||
# key: value
|
||||
# YAML
|
||||
|
||||
# Example: start a simple HTTP server (placeholder)
|
||||
# Replace with your actual app start command
|
||||
if command -v python3 >/dev/null 2>&1; then
|
||||
log "Launching placeholder server: python3 -m http.server ${APP_PORT}"
|
||||
exec python3 -m http.server "${APP_PORT}" --bind 0.0.0.0
|
||||
else
|
||||
abort "No application command configured. Replace placeholder with your app's start command."
|
||||
fi
|
||||
|
12
CloudronPackages/PackageTemplate/supervisord.conf
Normal file
12
CloudronPackages/PackageTemplate/supervisord.conf
Normal file
@@ -0,0 +1,12 @@
|
||||
[supervisord]
|
||||
logfile=/var/log/supervisor/supervisord.log
|
||||
pidfile=/run/supervisord.pid
|
||||
nodaemon=true
|
||||
|
||||
[program:app]
|
||||
command=/app/pkg/start.sh
|
||||
autorestart=true
|
||||
stdout_logfile=/var/log/supervisor/app.stdout.log
|
||||
stderr_logfile=/var/log/supervisor/app.stderr.log
|
||||
user=cloudron
|
||||
|
Reference in New Issue
Block a user