first commit
This commit is contained in:
commit
3c0479faf0
169 files changed
+27617
No files matched your search
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* Templates of the deployment procedure (procédure.md), used when a
|
||||
* project is created from the dashboard.
|
||||
*/
|
||||
|
||||
export type ProjectType = 'node' | 'adonis' | 'wordpress' | 'static'
|
||||
|
||||
const LOGGING = ` logging:
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"`
|
||||
|
||||
const NETWORKS = `networks:
|
||||
bdd_network:
|
||||
external: true
|
||||
caddy_network:
|
||||
external: true`
|
||||
|
||||
function nodeService(service: string, name: string, port: number, command: string) {
|
||||
return `services:
|
||||
${service}:
|
||||
image: node:22-alpine3.21
|
||||
container_name: ${name}
|
||||
working_dir: /app
|
||||
volumes:
|
||||
- ./project:/app
|
||||
command: sh -c "${command.replace(/"/g, '\\"')}"
|
||||
env_file: ./project/.env
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- HOST=0.0.0.0
|
||||
- PORT=${port}
|
||||
networks:
|
||||
- bdd_network
|
||||
- caddy_network
|
||||
restart: unless-stopped
|
||||
${LOGGING}
|
||||
|
||||
${NETWORKS}
|
||||
`
|
||||
}
|
||||
|
||||
export const DEFAULT_NODE_COMMAND = 'npm ci --omit=dev && node start.js'
|
||||
|
||||
export const ADONIS_COMMAND =
|
||||
'npm ci --include=dev && node ace build && cd build && npm ci --omit=dev && node bin/server.js'
|
||||
|
||||
export function composeFile(
|
||||
type: Exclude<ProjectType, 'static'>,
|
||||
name: string,
|
||||
port: number,
|
||||
command?: string
|
||||
) {
|
||||
switch (type) {
|
||||
case 'node':
|
||||
return nodeService('nodejs', name, port, command || DEFAULT_NODE_COMMAND)
|
||||
case 'adonis':
|
||||
return nodeService('adonis', name, port, ADONIS_COMMAND)
|
||||
case 'wordpress':
|
||||
return `services:
|
||||
wordpress:
|
||||
image: wordpress:php8.5-apache
|
||||
container_name: ${name}
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
WORDPRESS_DB_HOST: mariadb:3306
|
||||
WORDPRESS_DB_NAME: \${WP_DB_NAME}
|
||||
WORDPRESS_DB_USER: \${WP_DB_USER}
|
||||
WORDPRESS_DB_PASSWORD: \${WP_DB_PASSWORD}
|
||||
volumes:
|
||||
- ./wp_data:/var/www/html
|
||||
networks:
|
||||
- caddy_network
|
||||
- bdd_network
|
||||
${LOGGING}
|
||||
|
||||
${NETWORKS}
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
export function proxyBlock(domain: string, upstream: string) {
|
||||
return `${domain} {
|
||||
\treverse_proxy ${upstream}
|
||||
}`
|
||||
}
|
||||
|
||||
export function staticBlock(domain: string, root: string, spa: boolean) {
|
||||
return `${domain} {
|
||||
\troot * ${root}
|
||||
\tencode gzip
|
||||
\tfile_server${spa ? '\n\ttry_files {path} /index.html' : ''}
|
||||
}`
|
||||
}
|
||||
|
||||
export function placeholderPage(name: string) {
|
||||
return `<!doctype html>
|
||||
<html lang="fr">
|
||||
<head><meta charset="utf-8"><title>${name}</title></head>
|
||||
<body style="font-family: system-ui, sans-serif; display: grid; place-items: center; min-height: 100vh; margin: 0">
|
||||
<p>${name} : site en cours de déploiement.</p>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
}
|
||||
Reference in new issue
Block a user