Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
C
ctas-box
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Fachri
ctas-box
Commits
451823ac
Commit
451823ac
authored
Jan 29, 2026
by
Rais Aryaguna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add serve.json for caching headers and enhance deploy script with asset preservation
parent
2914d58d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
9 deletions
+61
-9
public/serve.json
public/serve.json
+31
-0
scripts/zero-dowtime/deploy.js
scripts/zero-dowtime/deploy.js
+30
-9
No files found.
public/serve.json
0 → 100644
View file @
451823ac
{
"headers"
:
[
{
"source"
:
"**/*"
,
"headers"
:
[
{
"key"
:
"Cache-Control"
,
"value"
:
"public, max-age=31536000, immutable"
}
]
},
{
"source"
:
"index.html"
,
"headers"
:
[
{
"key"
:
"Cache-Control"
,
"value"
:
"no-cache, no-store, must-revalidate"
}
]
},
{
"source"
:
"service-worker.js"
,
"headers"
:
[
{
"key"
:
"Cache-Control"
,
"value"
:
"no-cache, no-store, must-revalidate"
}
]
}
]
}
scripts/zero-dowtime/deploy.js
View file @
451823ac
#!/usr/bin/env node
#!/usr/bin/env node
/* eslint-disable no-shadow */
/* eslint-disable no-loop-func */
/* eslint-disable no-await-in-loop */
/**
/**
* Universal Zero Downtime Deployment Script
* Universal Zero Downtime Deployment Script
...
@@ -9,17 +6,16 @@
...
@@ -9,17 +6,16 @@
* All configurations loaded from environment variables
* All configurations loaded from environment variables
*/
*/
import
{
execSync
}
from
'
child_process
'
;
import
{
execSync
}
from
'
child_process
'
;
import
{
config
}
from
'
dotenv
'
;
import
fs
from
'
fs
'
;
import
fs
from
'
fs
'
;
import
http
from
'
http
'
;
import
path
from
'
path
'
;
import
path
from
'
path
'
;
import
{
fileURLToPath
}
from
'
url
'
;
import
{
fileURLToPath
}
from
'
url
'
;
import
http
from
'
http
'
;
import
{
config
}
from
'
dotenv
'
;
// Load environment-specific .env file
// Load environment-specific .env file
function
loadEnvConfig
(
environment
)
{
function
loadEnvConfig
(
environment
)
{
const
envFiles
=
[
`.env.
${
environment
}
.local`
,
`.env.
${
environment
}
`
,
'
.env.local
'
,
'
.env
'
];
const
envFiles
=
[
`.env.
${
environment
}
.local`
,
`.env.
${
environment
}
`
,
'
.env.local
'
,
'
.env
'
];
// eslint-disable-next-line no-restricted-syntax
for
(
const
envFile
of
envFiles
)
{
for
(
const
envFile
of
envFiles
)
{
const
envPath
=
path
.
join
(
process
.
cwd
(),
envFile
);
const
envPath
=
path
.
join
(
process
.
cwd
(),
envFile
);
if
(
fs
.
existsSync
(
envPath
))
{
if
(
fs
.
existsSync
(
envPath
))
{
...
@@ -76,9 +72,11 @@ const getConfig = (environment) => ({
...
@@ -76,9 +72,11 @@ const getConfig = (environment) => ({
let
CONFIG
;
let
CONFIG
;
// Helper functions
// Helper functions
// eslint-disable-next-line @typescript-eslint/no-shadow
function
logMessage
(
message
,
config
=
CONFIG
)
{
function
logMessage
(
message
,
config
=
CONFIG
)
{
const
timestamp
=
new
Date
().
toISOString
();
const
timestamp
=
new
Date
().
toISOString
();
// eslint-disable-next-line @typescript-eslint/no-shadow
const
logMessage
=
`[
${
timestamp
}
] [
${
config
?.
ENVIRONMENT
||
'
INIT
'
}]
$
{
message
}
`;
const
logMessage
=
`[
${
timestamp
}
] [
${
config
?.
ENVIRONMENT
||
'
INIT
'
}]
$
{
message
}
`;
if (!config || config.ENABLE_CONSOLE_LOG) {
if (!config || config.ENABLE_CONSOLE_LOG) {
...
@@ -128,7 +126,6 @@ async function checkHealth(retries = CONFIG.HEALTH_CHECK_RETRIES) {
...
@@ -128,7 +126,6 @@ async function checkHealth(retries = CONFIG.HEALTH_CHECK_RETRIES) {
logMessage
(
`🏥 Starting health check (
${
retries
}
retries)...`
);
logMessage
(
`🏥 Starting health check (
${
retries
}
retries)...`
);
// eslint-disable-next-line no-plusplus
for
(
let
i
=
0
;
i
<
retries
;
i
++
)
{
for
(
let
i
=
0
;
i
<
retries
;
i
++
)
{
try
{
try
{
await
new
Promise
((
resolve
,
reject
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
...
@@ -171,6 +168,31 @@ function atomicFolderSwitch() {
...
@@ -171,6 +168,31 @@ function atomicFolderSwitch() {
const
finalPath
=
path
.
join
(
process
.
cwd
(),
CONFIG
.
FINAL_DIST_DIR
);
const
finalPath
=
path
.
join
(
process
.
cwd
(),
CONFIG
.
FINAL_DIST_DIR
);
const
backupPath
=
path
.
join
(
process
.
cwd
(),
CONFIG
.
BACKUP_DIST_DIR
);
const
backupPath
=
path
.
join
(
process
.
cwd
(),
CONFIG
.
BACKUP_DIST_DIR
);
// Preserve old assets to prevent 404s during transition
logMessage
(
'
📦 Preserving old assets to prevent 404s...
'
);
const
oldAssetsDir
=
path
.
join
(
finalPath
,
'
assets
'
);
const
newAssetsDir
=
path
.
join
(
tmpPath
,
'
assets
'
);
if
(
fs
.
existsSync
(
oldAssetsDir
)
&&
fs
.
existsSync
(
newAssetsDir
))
{
try
{
const
files
=
fs
.
readdirSync
(
oldAssetsDir
);
let
copiedCount
=
0
;
for
(
const
file
of
files
)
{
const
srcFile
=
path
.
join
(
oldAssetsDir
,
file
);
const
destFile
=
path
.
join
(
newAssetsDir
,
file
);
if
(
!
fs
.
existsSync
(
destFile
))
{
fs
.
copyFileSync
(
srcFile
,
destFile
);
copiedCount
+=
1
;
}
}
logMessage
(
`✅ Preserved
${
copiedCount
}
old asset files.`
);
}
catch
(
error
)
{
logMessage
(
`⚠️ Failed to preserve assets:
${
error
.
message
}
`
);
}
}
// Create backup of current dist
// Create backup of current dist
if
(
fs
.
existsSync
(
finalPath
))
{
if
(
fs
.
existsSync
(
finalPath
))
{
if
(
fs
.
existsSync
(
backupPath
))
{
if
(
fs
.
existsSync
(
backupPath
))
{
...
@@ -444,5 +466,4 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
...
@@ -444,5 +466,4 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
deployApp
(
environment
);
deployApp
(
environment
);
}
}
// eslint-disable-next-line import/prefer-default-export
export
{
deployApp
};
export
{
deployApp
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment