From ba39cb4af781d5f0893d17ac68bb85783a2b4980 Mon Sep 17 00:00:00 2001 From: Knight Date: Sat, 28 Dec 2024 10:56:15 -0500 Subject: [PATCH] Refactor Dockerfile to execute start.sh and update .gitignore to exclude *.png files. Enhance fetchImages.js with improved path normalization and debug logging for asset checks, ensuring more reliable image fetching and processing. --- .gitignore | 1 - Dockerfile | 3 ++- docker-compose.yml | 2 +- fetchImages.js | 18 ++++++++++-------- public/AnalogCamera.png | Bin 0 -> 909 bytes public/AnalogCameraS.png | Bin 0 -> 969 bytes public/favicon.png | Bin 0 -> 969 bytes start.sh | 3 +++ 8 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 public/AnalogCamera.png create mode 100644 public/AnalogCameraS.png create mode 100644 public/favicon.png create mode 100644 start.sh diff --git a/.gitignore b/.gitignore index 298afe3..1717902 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ dist build images/ *.html -*.png *.jpg *.jpeg *.gif diff --git a/Dockerfile b/Dockerfile index 733ed8e..0128ac1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,5 +5,6 @@ COPY package.json package-lock.json ./ RUN npm install COPY . . +RUN chmod +x start.sh -CMD ["sh", "-c", "node fetchImages.js && node generateSite.js"] +CMD ["./start.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index 94de1c3..cbbd0d4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,8 +4,8 @@ services: gallery: build: . volumes: - - ./public:/app/public - ./images:/app/images + - ./images.json:/app/images.json expose: - "3000" environment: diff --git a/fetchImages.js b/fetchImages.js index e805e8f..2d33786 100644 --- a/fetchImages.js +++ b/fetchImages.js @@ -62,20 +62,22 @@ async function getAlbumAssets() { const fileName = `${asset.id}_${asset.originalFileName || 'untitled'}`; const outputPath = path.join(config.outputDir, fileName); - // Add debug logging to understand the state - console.log(`Checking asset ${asset.id}:`); - console.log(`- Expected path: ${outputPath}`); - // Check if file already exists and is in our metadata const existingImage = existingImages.find(img => img.id === asset.id); if (existingImage) { - console.log(`- Found in metadata: ${existingImage.localPath}`); - if (fs.existsSync(existingImage.localPath)) { - console.log(`- File exists on disk, skipping download`); + // Normalize the paths to ensure consistent comparison + const normalizedExistingPath = path.normalize(existingImage.localPath); + const normalizedOutputPath = path.normalize(outputPath); + + console.log(`Checking paths:`); + console.log(`- Current path: ${normalizedOutputPath}`); + console.log(`- Existing path: ${normalizedExistingPath}`); + + if (fs.existsSync(normalizedOutputPath)) { + console.log(`File exists, skipping: ${fileName}`); images.push(existingImage); continue; } - console.log(`- File not found on disk at ${existingImage.localPath}`); } console.log(`Downloading: ${fileName}`); diff --git a/public/AnalogCamera.png b/public/AnalogCamera.png new file mode 100644 index 0000000000000000000000000000000000000000..c335963002a6602ae844f88dd48a77e3e91c0368 GIT binary patch literal 909 zcmeAS@N?(olHy`uVBq!ia0vp^1wib;!3HD`&HDTdNHG=%xjQkeJ16s!fq~iG)5S5Q zV$R#S_8B690>{2LxdtrKcorlRc+ji2O@Z;En#%;^8(ujkNm8y)_&SA{%O*ML>^Y_7 zwSjA+@e4(XH7W}KlmofBc|UR~YpJjVt^8WUoi9^n{zm5hdg*U(Z;m@Is(w*z-)86L`-rr*!wP8(uY3*78t9f5)mK-&j@r0l2g$xi~ z{%gj4L0GE0_rZ@#?d{mw97-26eVeo0Bhk@DBVO6#VzAN?tuFW31vUd)bNJmo9T+2&*U{oOkj*M=9= zJiX;Am>gIB?ZtwQc%3s{70(VP3;JJw`uzG1t02)rptFA1eaz>1=kPoLj6^Pc-cZ(F zdH!YX(+4dtD#Opk^Y#7Tyyf5i?A}EhU2^;82yJ|JG1K_(O1-2nN2Z;-=JNTxU9D2m znzxJ8i`lK(nLtSWS>p@Mh-{ZFHaeOWwYjyk+@oh^@9`_O)BdZ@-gJB?^IT^}5E5S9 z`mOXUyZ?b(^GpAn`JAqFEo=UZ%o**9Yj1C7?eD+h)_iEFD%bP8T$a!ZYaIq>u zU~RvN=CyhA)*vL-sHfEz_P^*nd3(2@)D7jud;L2S=C8gMJo)Q$_Zz~OQy}3#!?s}Y z`=1?Gg$wu2IG&kto_q5@y9<*qUWNzS;%iPD`HinlUbIJk#+3Qp@b8Rb literal 0 HcmV?d00001 diff --git a/public/AnalogCameraS.png b/public/AnalogCameraS.png new file mode 100644 index 0000000000000000000000000000000000000000..ab9ddc46e090bc146167fad9f4a42d6bcc56df0e GIT binary patch literal 969 zcmeAS@N?(olHy`uVBq!ia0vp^6(G#P1|%(0%q{^b#^NA%Cx&(BWL`2bFgJU;IEGZr zd3)E_BP3Adz{kKSo>te1kCQeug-ulza=PNilQd~t;%uX$U>A+Vg-*K*1a*ZLg^6AA z%9(yeKxM5{$G!_$7Z)8#n;6)rv}4t^=R9`~KixZXneqSo?>^Y2^Ib1~U;DjxCJ)eB zbZ{j5$940B%u{*4gm2y3wbQbq=J3RcF4yh1{+`~k{;rJJ{h6ipt6ygyd~fmc2mp#hG#?n->^xwXF zc7m^^GJ8+^%h-yQ?p=~`@EpX#G~R2b!PjRv|7=#;7dl7aW5U9C8T*gF7T)+*`7rpy zuZ^asS2ZS^A9J~LX^--b{|BaiR=W21*5&qU*FQChVMmO=%Xe1n(y-tE^wWg}9k;Em zk9^PU?aqW5o?5@Z^z7B*HS3y%iDqr>>wjzPoYw5Tv^wOx`0C#k z{sq6^p0vL5pvtLfuJXZiGm9_A=H5N{w(6Z}+5eg8{;oM^ZC}q?b$nq|+3RT!zAgOt z@Il$zUy?h|MaA2{wL5Y5W3|#gg95!*6;T_CRX`y+XXi1qGTzXo#}8KJ-JHdJtpw+ApaFJ!fL2TLxE zYi6HT-&J9=UH7dw$LH1eUG7Z1DPFo~9(TX2_;o9og)wLQo7e7)>#qB^Ch~F8>$)vl zr>< zp=fS?83{1OQk+;@|)P literal 0 HcmV?d00001 diff --git a/public/favicon.png b/public/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..ab9ddc46e090bc146167fad9f4a42d6bcc56df0e GIT binary patch literal 969 zcmeAS@N?(olHy`uVBq!ia0vp^6(G#P1|%(0%q{^b#^NA%Cx&(BWL`2bFgJU;IEGZr zd3)E_BP3Adz{kKSo>te1kCQeug-ulza=PNilQd~t;%uX$U>A+Vg-*K*1a*ZLg^6AA z%9(yeKxM5{$G!_$7Z)8#n;6)rv}4t^=R9`~KixZXneqSo?>^Y2^Ib1~U;DjxCJ)eB zbZ{j5$940B%u{*4gm2y3wbQbq=J3RcF4yh1{+`~k{;rJJ{h6ipt6ygyd~fmc2mp#hG#?n->^xwXF zc7m^^GJ8+^%h-yQ?p=~`@EpX#G~R2b!PjRv|7=#;7dl7aW5U9C8T*gF7T)+*`7rpy zuZ^asS2ZS^A9J~LX^--b{|BaiR=W21*5&qU*FQChVMmO=%Xe1n(y-tE^wWg}9k;Em zk9^PU?aqW5o?5@Z^z7B*HS3y%iDqr>>wjzPoYw5Tv^wOx`0C#k z{sq6^p0vL5pvtLfuJXZiGm9_A=H5N{w(6Z}+5eg8{;oM^ZC}q?b$nq|+3RT!zAgOt z@Il$zUy?h|MaA2{wL5Y5W3|#gg95!*6;T_CRX`y+XXi1qGTzXo#}8KJ-JHdJtpw+ApaFJ!fL2TLxE zYi6HT-&J9=UH7dw$LH1eUG7Z1DPFo~9(TX2_;o9og)wLQo7e7)>#qB^Ch~F8>$)vl zr>< zp=fS?83{1OQk+;@|)P literal 0 HcmV?d00001 diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..eb6a2bb --- /dev/null +++ b/start.sh @@ -0,0 +1,3 @@ +#!/bin/sh +node generateSite.js & # Run the site generator in background +node fetchImages.js # Run the image fetcher in foreground \ No newline at end of file