105 lines
2.8 KiB
TypeScript
105 lines
2.8 KiB
TypeScript
import { Template } from '@easypanel/template-sdk';
|
|
|
|
// This secure template generates the docker-compose and uses environment variables
|
|
// so that secrets are not stored in files inside the project. Instead, config
|
|
// is generated at container start from env vars injected by the panel.
|
|
|
|
const t: Template = {
|
|
meta: require('./meta.yaml'),
|
|
render: (values: any) => {
|
|
const libVersion = values.libretime_version || '4.5';
|
|
const publicUrl = values.public_url || 'http://{{hostname}}:8080';
|
|
|
|
const compose = `version: '3.8'
|
|
services:
|
|
postgres:
|
|
image: postgres:15
|
|
environment:
|
|
POSTGRES_USER: libretime
|
|
POSTGRES_PASSWORD: ${values.postgres_password ? `'${values.postgres_password}'` : "\"\""}
|
|
POSTGRES_DB: libretime
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
|
|
rabbitmq:
|
|
image: rabbitmq:3.13-alpine
|
|
environment:
|
|
RABBITMQ_DEFAULT_VHOST: /libretime
|
|
RABBITMQ_DEFAULT_USER: libretime
|
|
RABBITMQ_DEFAULT_PASS: ${values.rabbitmq_password ? `'${values.rabbitmq_password}'` : "\"\""}
|
|
|
|
api:
|
|
image: ghcr.io/libretime/libretime-api:${libVersion}
|
|
environment:
|
|
- LIBRETIME_GENERAL_PUBLIC_URL=${publicUrl}
|
|
- LIBRETIME_CONFIG_FROM_ENV=true
|
|
volumes:
|
|
- libretime_storage:/srv/libretime
|
|
depends_on:
|
|
- postgres
|
|
- rabbitmq
|
|
|
|
# composer not included; follow standard LibreTime docker installation
|
|
|
|
legacy:
|
|
image: ghcr.io/libretime/libretime-legacy:${libVersion}
|
|
environment:
|
|
- LIBRETIME_CONFIG_FROM_ENV=true
|
|
volumes:
|
|
- libretime_storage:/srv/libretime
|
|
depends_on:
|
|
- postgres
|
|
- rabbitmq
|
|
|
|
nginx:
|
|
image: ghcr.io/libretime/libretime-nginx:${libVersion}
|
|
ports:
|
|
- "8080:8080"
|
|
volumes:
|
|
- libretime_storage:/srv/libretime:ro
|
|
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
|
depends_on:
|
|
- legacy
|
|
- api
|
|
|
|
volumes:
|
|
postgres_data:
|
|
libretime_storage:
|
|
`;
|
|
|
|
const startupSh = `#!/bin/sh
|
|
# At container start this script writes /etc/libretime/config.yml from env
|
|
cat > /etc/libretime/config.yml <<EOF
|
|
general:
|
|
public_url: ${publicUrl}
|
|
api_key: "${values.api_key || ''}"
|
|
secret_key: "${values.secret_key || ''}"
|
|
|
|
database:
|
|
host: ${values.database_host || 'postgres'}
|
|
port: 5432
|
|
name: libretime
|
|
user: libretime
|
|
password: "$POSTGRES_PASSWORD"
|
|
|
|
rabbitmq:
|
|
host: ${values.rabbitmq_host || 'rabbitmq'}
|
|
port: 5672
|
|
vhost: /libretime
|
|
user: libretime
|
|
password: "$RABBITMQ_DEFAULT_PASS"
|
|
EOF
|
|
`;
|
|
|
|
return {
|
|
files: [
|
|
{ path: 'docker-compose.yml', content: compose },
|
|
{ path: 'startup/generate-config.sh', content: startupSh },
|
|
{ path: 'docker/nginx/default.conf', content: require('fs').readFileSync('docker/nginx/default.conf','utf8') },
|
|
],
|
|
};
|
|
},
|
|
};
|
|
|
|
export default t;
|