Frontend dev dockerfile: Check if node_modules exist and install if not on startup

This commit is contained in:
ShootingStar91
2024-08-24 15:54:04 +03:00
parent 61d4491a6e
commit 0f9ca24673
3 changed files with 4 additions and 6 deletions
+3 -3
View File
@@ -44,16 +44,16 @@ export const testDbConnection = async () => {
return false
}
}
const maxAttempts = 20
const maxAttempts = 25
let attempts = 0
while (attempts < maxAttempts) {
const success = await tryDbConnection()
if (success) {
return
}
logger.info(`Trying again in 6 seconds, attempt ${attempts} / ${maxAttempts}`)
logger.info(`Trying again in 4 seconds, attempt ${attempts} / ${maxAttempts}`)
attempts++
await sleep(6000)
await sleep(4000)
}
logger.error(`Attempted ${maxAttempts} times, but database connection could not be established`)
}
-2
View File
@@ -8,8 +8,6 @@ COPY package.json ./
COPY package-lock.json ./
RUN npm ci
EXPOSE 5173
CMD ["npm", "run", "dev", "--", "--host"]
+1 -1
View File
@@ -4,7 +4,7 @@
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "[ -d node_modules ] && npx vite || npm ci && npx vite",
"build": "vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"