mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-06-06 17:39:57 +00:00
fix: cache images so docker-compose can work offline
This commit is contained in:
parent
0736926e37
commit
3c8cdebc18
@ -9,6 +9,7 @@ x-pg-environment: &pg_env
|
|||||||
# Shared nwaku configuration
|
# Shared nwaku configuration
|
||||||
x-nwaku-base: &nwaku-base
|
x-nwaku-base: &nwaku-base
|
||||||
image: ${NWAKU_IMAGE:-wakuorg/nwaku:v0.36.0}
|
image: ${NWAKU_IMAGE:-wakuorg/nwaku:v0.36.0}
|
||||||
|
pull_policy: if_not_present
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
logging:
|
logging:
|
||||||
driver: json-file
|
driver: json-file
|
||||||
@ -19,6 +20,7 @@ x-nwaku-base: &nwaku-base
|
|||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:15.4-alpine3.18
|
image: postgres:15.4-alpine3.18
|
||||||
|
pull_policy: if_not_present
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
environment:
|
environment:
|
||||||
<<: *pg_env
|
<<: *pg_env
|
||||||
|
|||||||
@ -25,6 +25,39 @@ const colors: Colors = {
|
|||||||
yellow: "\x1b[33m"
|
yellow: "\x1b[33m"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function checkAndPullImages(): void {
|
||||||
|
const nwakuImage = process.env.NWAKU_IMAGE || "wakuorg/nwaku:v0.36.0";
|
||||||
|
const postgresImage = "postgres:15.4-alpine3.18";
|
||||||
|
const images = [
|
||||||
|
{ name: nwakuImage, label: "nwaku" },
|
||||||
|
{ name: postgresImage, label: "postgres" }
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const { name, label } of images) {
|
||||||
|
try {
|
||||||
|
// Check if image exists locally
|
||||||
|
const imageId = execSync(`docker images -q ${name}`, {
|
||||||
|
encoding: "utf-8"
|
||||||
|
}).trim();
|
||||||
|
|
||||||
|
if (!imageId) {
|
||||||
|
// Image doesn't exist, pull it
|
||||||
|
process.stdout.write(
|
||||||
|
`${colors.cyan}Pulling ${label} image (${name})...${colors.reset}\n`
|
||||||
|
);
|
||||||
|
execSync(`docker pull ${name}`, { stdio: "inherit" });
|
||||||
|
process.stdout.write(
|
||||||
|
`${colors.green}✓${colors.reset} ${label} image ready\n`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
process.stderr.write(
|
||||||
|
`${colors.yellow}⚠${colors.reset} Failed to check/pull ${label} image. Continuing anyway...\n`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function waitWithProgress(ms: number): Promise<void> {
|
async function waitWithProgress(ms: number): Promise<void> {
|
||||||
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
@ -55,6 +88,9 @@ process.stdout.write(
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Check and pull images if needed
|
||||||
|
checkAndPullImages();
|
||||||
|
|
||||||
// Start docker compose quietly
|
// Start docker compose quietly
|
||||||
execSync("docker compose up -d", {
|
execSync("docker compose up -d", {
|
||||||
stdio: ["ignore", "ignore", "pipe"],
|
stdio: ["ignore", "ignore", "pipe"],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user