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.

This commit is contained in:
Knight 2024-12-28 10:56:15 -05:00
parent 09a34e2f38
commit ba39cb4af7
8 changed files with 16 additions and 11 deletions

1
.gitignore vendored
View File

@ -3,7 +3,6 @@ dist
build
images/
*.html
*.png
*.jpg
*.jpeg
*.gif

View File

@ -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"]

View File

@ -4,8 +4,8 @@ services:
gallery:
build: .
volumes:
- ./public:/app/public
- ./images:/app/images
- ./images.json:/app/images.json
expose:
- "3000"
environment:

View File

@ -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}`);

BIN
public/AnalogCamera.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

BIN
public/AnalogCameraS.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

BIN
public/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

3
start.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
node generateSite.js & # Run the site generator in background
node fetchImages.js # Run the image fetcher in foreground