diff --git a/Dockerfile.dev b/Dockerfile.dev index 92d659a..ed9e76b 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -72,14 +72,23 @@ ENV APP_SHELL_PORT=4000 CMD ["sh", "-c", "\ - yarn --cwd /app/frontend dev & echo $! > /app/pids/frontend.pid && \ - yarn --cwd /app/backend start & echo $! > /app/pids/backend.pid && \ - sleep 10 && nginx -g 'daemon off;' & \ - NGINX_PID=$! && \ - echo 'Waiting for backend (port 3000) to be available...' && \ + set -e; \ + echo 'Preparing repository before starting app processes...' ; \ + yarn --cwd /app/app-shell init-repo; \ + yarn --cwd /app/frontend dev & echo $! > /app/pids/frontend.pid; \ + yarn --cwd /app/backend start & echo $! > /app/pids/backend.pid; \ + APP_SHELL_SKIP_REPO_INIT=true yarn --cwd /app/app-shell start & echo $! > /app/pids/app-shell.pid; \ + echo 'Waiting for frontend (port 3001) to be available...' ; \ + while ! nc -z localhost ${FRONT_PORT}; do \ + sleep 2; \ + done; \ + echo 'Waiting for backend (port 3000) to be available...' ; \ while ! nc -z localhost ${BACKEND_PORT}; do \ sleep 2; \ - done && \ - echo 'Backend is up. Starting app_shell for Git check...' && \ - yarn --cwd /app/app-shell start && \ - wait $NGINX_PID"] + done; \ + echo 'Waiting for app_shell (port 4000) to be available...' ; \ + while ! nc -z localhost ${APP_SHELL_PORT}; do \ + sleep 2; \ + done; \ + echo 'All app processes are up. Starting nginx...' ; \ + exec nginx -g 'daemon off;'"] diff --git a/app-shell/package.json b/app-shell/package.json index 12c9700..08bafaf 100644 --- a/app-shell/package.json +++ b/app-shell/package.json @@ -2,6 +2,7 @@ "name": "app-shell", "description": "app-shell", "scripts": { + "init-repo": "node ./src/init-repo.js", "start": "node ./src/index.js" }, "dependencies": { diff --git a/app-shell/src/index.js b/app-shell/src/index.js index 5bb6053..ff61262 100644 --- a/app-shell/src/index.js +++ b/app-shell/src/index.js @@ -32,8 +32,7 @@ function runGitCheck() { }) .catch(err => { console.error('Error during repo initialization:', err); - // Optionally exit the process if Git check is critical: - // process.exit(1); + process.exit(1); }); } @@ -48,7 +47,8 @@ app.use('/vcs', vcsRoutes); // Start the app_shell server startServer(); -// Now perform Git check -runGitCheck(); +if (process.env.APP_SHELL_SKIP_REPO_INIT !== 'true') { + runGitCheck(); +} module.exports = app; diff --git a/app-shell/src/init-repo.js b/app-shell/src/init-repo.js new file mode 100644 index 0000000..5e0802c --- /dev/null +++ b/app-shell/src/init-repo.js @@ -0,0 +1,16 @@ +const VCS = require('./services/vcs'); + +const projectId = '32694'; + +VCS.initRepo(projectId) + .then((result) => { + if (result && result.message) { + console.log(result.message); + } else { + console.log(result); + } + }) + .catch((error) => { + console.error('Error during repo initialization:', error); + process.exit(1); + });