docker fix
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import compression from 'compression';
|
import compression from 'compression';
|
||||||
import { execSync } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
|
import { promisify } from 'util';
|
||||||
import { existsSync, mkdirSync, cpSync, rmSync, readdirSync, readFileSync } from 'fs';
|
import { existsSync, mkdirSync, cpSync, rmSync, readdirSync, readFileSync } from 'fs';
|
||||||
import { join, dirname } from 'path';
|
import { join, dirname } from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const execAsync = promisify(exec);
|
||||||
|
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
const PORT = process.env.PORT || 3000;
|
const PORT = process.env.PORT || 3000;
|
||||||
@@ -35,9 +38,11 @@ function findLatestRelease() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function run(cmd, opts = {}) {
|
async function run(cmd, opts = {}) {
|
||||||
log(`> ${cmd}`);
|
log(`> ${cmd}`);
|
||||||
execSync(cmd, { stdio: 'inherit', timeout: 600_000, ...opts });
|
const { stdout, stderr } = await execAsync(cmd, { timeout: 600_000, maxBuffer: 50 * 1024 * 1024, ...opts });
|
||||||
|
if (stdout) process.stdout.write(stdout);
|
||||||
|
if (stderr) process.stderr.write(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function triggerBuild(webhookCommit) {
|
async function triggerBuild(webhookCommit) {
|
||||||
@@ -60,10 +65,11 @@ async function triggerBuild(webhookCommit) {
|
|||||||
log('Starting build...');
|
log('Starting build...');
|
||||||
|
|
||||||
// Clone
|
// Clone
|
||||||
run(`git clone --depth 1 --branch ${GIT_BRANCH} ${GIT_REPO_URL} ${buildDir}`);
|
await run(`git clone --depth 1 --branch ${GIT_BRANCH} ${GIT_REPO_URL} ${buildDir}`);
|
||||||
|
|
||||||
// Read the cloned commit hash
|
// Read the cloned commit hash
|
||||||
const clonedHash = execSync('git rev-parse HEAD', { cwd: buildDir, encoding: 'utf-8' }).trim();
|
const { stdout: hashOut } = await execAsync('git rev-parse HEAD', { cwd: buildDir });
|
||||||
|
const clonedHash = hashOut.trim();
|
||||||
log(`Cloned commit: ${clonedHash}`);
|
log(`Cloned commit: ${clonedHash}`);
|
||||||
|
|
||||||
// Skip if this commit is already deployed
|
// Skip if this commit is already deployed
|
||||||
@@ -74,14 +80,14 @@ async function triggerBuild(webhookCommit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Install deps (web workspaces only)
|
// Install deps (web workspaces only)
|
||||||
run(
|
await run(
|
||||||
'npm ci --workspace=apps/web --workspace=packages/shared --workspace=packages/platform-web --include-workspace-root',
|
'npm ci --workspace=apps/web --workspace=packages/shared --workspace=packages/platform-web --include-workspace-root',
|
||||||
{ cwd: buildDir }
|
{ cwd: buildDir }
|
||||||
);
|
);
|
||||||
|
|
||||||
// Build
|
// Build
|
||||||
const env = { ...process.env, VITE_CONVEX_URL, VITE_LIVEKIT_URL };
|
const env = { ...process.env, VITE_CONVEX_URL, VITE_LIVEKIT_URL };
|
||||||
run('npm run build:web', { cwd: buildDir, env });
|
await run('npm run build:web', { cwd: buildDir, env });
|
||||||
|
|
||||||
// Copy dist to release dir
|
// Copy dist to release dir
|
||||||
const distDir = join(buildDir, 'apps', 'web', 'dist');
|
const distDir = join(buildDir, 'apps', 'web', 'dist');
|
||||||
|
|||||||
Reference in New Issue
Block a user