feat: implement centralized Docker base-image strategy and automate registry pushes
This commit is contained in:
@@ -318,34 +318,56 @@ export default function Home() {
|
||||
// Copy infra templates
|
||||
const infraPath = path.resolve(__dirname, "../../infra");
|
||||
if (await fs.pathExists(infraPath)) {
|
||||
await fs.copy(
|
||||
path.join(infraPath, "docker/Dockerfile.nextjs"),
|
||||
path.join(fullPath, "Dockerfile"),
|
||||
// Setup Dockerfile from template
|
||||
const templatePath = path.join(
|
||||
infraPath,
|
||||
"docker/Dockerfile.app-template",
|
||||
);
|
||||
await fs.copy(
|
||||
path.join(infraPath, "docker/docker-compose.template.yml"),
|
||||
path.join(fullPath, "docker-compose.yml"),
|
||||
if (await fs.pathExists(templatePath)) {
|
||||
let dockerfile = await fs.readFile(templatePath, "utf8");
|
||||
dockerfile = dockerfile.replace(/\$\{APP_NAME:-app\}/g, projectName);
|
||||
await fs.writeFile(path.join(fullPath, "Dockerfile"), dockerfile);
|
||||
}
|
||||
|
||||
// Setup docker-compose from template
|
||||
const composeTemplatePath = path.join(
|
||||
infraPath,
|
||||
"docker/docker-compose.template.yml",
|
||||
);
|
||||
if (await fs.pathExists(composeTemplatePath)) {
|
||||
let compose = await fs.readFile(composeTemplatePath, "utf8");
|
||||
compose = compose.replace(/\$\{APP_NAME:-app\}/g, projectName);
|
||||
compose = compose.replace(/\$\{PROJECT_NAME:-app\}/g, projectName);
|
||||
await fs.writeFile(
|
||||
path.join(fullPath, "docker-compose.yml"),
|
||||
compose,
|
||||
);
|
||||
}
|
||||
|
||||
await fs.ensureDir(path.join(fullPath, ".gitea/workflows"));
|
||||
await fs.copy(
|
||||
path.join(infraPath, "gitea/deploy-action.yml"),
|
||||
path.join(fullPath, ".gitea/workflows/deploy.yml"),
|
||||
const deployActionPath = path.join(
|
||||
infraPath,
|
||||
"gitea/deploy-action.yml",
|
||||
);
|
||||
if (await fs.pathExists(deployActionPath)) {
|
||||
await fs.copy(
|
||||
deployActionPath,
|
||||
path.join(fullPath, ".gitea/workflows/deploy.yml"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Create Directus structure
|
||||
await fs.ensureDir(path.join(fullPath, "directus/uploads"));
|
||||
await fs.ensureDir(path.join(fullPath, "directus/extensions"));
|
||||
await fs.writeFile(
|
||||
path.join(fullPath, "directus/uploads/.gitkeep"),
|
||||
"",
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(fullPath, "directus/extensions/.gitkeep"),
|
||||
"",
|
||||
);
|
||||
// Create Directus structure
|
||||
await fs.ensureDir(path.join(fullPath, "directus/uploads"));
|
||||
await fs.ensureDir(path.join(fullPath, "directus/extensions"));
|
||||
await fs.writeFile(path.join(fullPath, "directus/uploads/.gitkeep"), "");
|
||||
await fs.writeFile(
|
||||
path.join(fullPath, "directus/extensions/.gitkeep"),
|
||||
"",
|
||||
);
|
||||
|
||||
// Create .env.example
|
||||
const envExample = `# Project
|
||||
// Create .env.example
|
||||
const envExample = `# Project
|
||||
PROJECT_NAME=${projectName}
|
||||
PROJECT_COLOR=#82ed20
|
||||
|
||||
@@ -377,14 +399,13 @@ SENTRY_DSN=
|
||||
NEXT_PUBLIC_UMAMI_WEBSITE_ID=
|
||||
NEXT_PUBLIC_UMAMI_SCRIPT_URL=https://analytics.infra.mintel.me/script.js
|
||||
`;
|
||||
await fs.writeFile(path.join(fullPath, ".env.example"), envExample);
|
||||
await fs.writeFile(path.join(fullPath, ".env.example"), envExample);
|
||||
|
||||
// Copy premium templates (globals.css, lib/directus.ts, scripts/setup-directus.ts)
|
||||
const templatePath = path.join(infraPath, "templates/website");
|
||||
if (await fs.pathExists(templatePath)) {
|
||||
console.log(chalk.blue("Applying premium templates..."));
|
||||
await fs.copy(templatePath, fullPath, { overwrite: true });
|
||||
}
|
||||
// Copy premium templates (globals.css, lib/directus.ts, scripts/setup-directus.ts)
|
||||
const templatePath = path.join(infraPath, "templates/website");
|
||||
if (await fs.pathExists(templatePath)) {
|
||||
console.log(chalk.blue("Applying premium templates..."));
|
||||
await fs.copy(templatePath, fullPath, { overwrite: true });
|
||||
}
|
||||
|
||||
console.log(
|
||||
|
||||
Reference in New Issue
Block a user