mirror of
https://github.com/ergosteur/instaarchive-viewer.git
synced 2026-07-04 11:07:15 -04:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5267dab236 |
21
README.md
21
README.md
@@ -25,6 +25,8 @@ docker run -d \
|
|||||||
ghcr.io/ergosteur/instaarchive-viewer:latest
|
ghcr.io/ergosteur/instaarchive-viewer:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> **Note for Linux/SELinux users:** If you see "Permission Denied" in the logs, append `,z` to your volume mount: `-v /path/to/archives:/archives:ro,z`
|
||||||
|
|
||||||
### Docker Compose
|
### Docker Compose
|
||||||
|
|
||||||
Create a `compose.yml` file:
|
Create a `compose.yml` file:
|
||||||
@@ -36,13 +38,22 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
volumes:
|
volumes:
|
||||||
- ./archives:/archives:ro
|
- ./archives:/archives:ro,z # ,z handles SELinux permissions
|
||||||
```
|
```
|
||||||
|
|
||||||
Run with:
|
### Troubleshooting Permissions
|
||||||
```bash
|
|
||||||
docker compose up -d
|
If the app shows "No Archives Found" and logs `EACCES: permission denied`:
|
||||||
```
|
|
||||||
|
1. **Check Directory Permissions**: Ensure the archive folder is world-readable:
|
||||||
|
```bash
|
||||||
|
chmod -R 755 /path/to/archives
|
||||||
|
```
|
||||||
|
2. **SELinux (Fedora/RHEL/CentOS)**: Use the `:z` flag in your volume mount as shown above.
|
||||||
|
3. **User Mapping**: You can force the container to run as your host user:
|
||||||
|
```bash
|
||||||
|
docker run --user $(id -u):$(id -g) ...
|
||||||
|
```
|
||||||
|
|
||||||
## Supported Archive Structure
|
## Supported Archive Structure
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
services:
|
services:
|
||||||
instaarchive:
|
instaarchive:
|
||||||
image: ghcr.io/${GITHUB_REPOSITORY:-ergosteur/instaarchive-viewer}:latest
|
image: ghcr.io/ergosteur/instaarchive-viewer:latest
|
||||||
build: .
|
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
volumes:
|
volumes:
|
||||||
- ./archives:/archives:ro
|
- ./archives:/archives:ro,z
|
||||||
environment:
|
environment:
|
||||||
- PORT=3000
|
- PORT=3000
|
||||||
- ARCHIVES_DIR=/archives
|
- ARCHIVES_DIR=/archives
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "react-example",
|
"name": "react-example",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --port=3000 --host=0.0.0.0",
|
"dev": "vite --port=3000 --host=0.0.0.0",
|
||||||
|
|||||||
23
server.ts
23
server.ts
@@ -3,6 +3,7 @@ import fs from 'fs';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@@ -14,13 +15,18 @@ const PORT = process.env.PORT || 3001;
|
|||||||
const ARCHIVES_DIR = path.resolve(process.env.ARCHIVES_DIR || path.join(__dirname, '_sample-archives'));
|
const ARCHIVES_DIR = path.resolve(process.env.ARCHIVES_DIR || path.join(__dirname, '_sample-archives'));
|
||||||
|
|
||||||
console.log(`[Server] Initializing...`);
|
console.log(`[Server] Initializing...`);
|
||||||
|
console.log(`[Server] Running as user: ${os.userInfo().username} (UID: ${os.userInfo().uid}, GID: ${os.userInfo().gid})`);
|
||||||
console.log(`[Server] Environment ARCHIVES_DIR: ${process.env.ARCHIVES_DIR}`);
|
console.log(`[Server] Environment ARCHIVES_DIR: ${process.env.ARCHIVES_DIR}`);
|
||||||
console.log(`[Server] Resolved ARCHIVES_DIR: ${ARCHIVES_DIR}`);
|
console.log(`[Server] Resolved ARCHIVES_DIR: ${ARCHIVES_DIR}`);
|
||||||
|
|
||||||
// Ensure archives directory exists
|
// Ensure archives directory exists
|
||||||
if (!fs.existsSync(ARCHIVES_DIR)) {
|
if (!fs.existsSync(ARCHIVES_DIR)) {
|
||||||
console.warn(`[Server] Warning: Archives directory not found at ${ARCHIVES_DIR}. Creating it...`);
|
console.warn(`[Server] Warning: Archives directory not found at ${ARCHIVES_DIR}. Creating it...`);
|
||||||
|
try {
|
||||||
fs.mkdirSync(ARCHIVES_DIR, { recursive: true });
|
fs.mkdirSync(ARCHIVES_DIR, { recursive: true });
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`[Server] Failed to create archives directory:`, err);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(`[Server] Archives directory exists.`);
|
console.log(`[Server] Archives directory exists.`);
|
||||||
}
|
}
|
||||||
@@ -43,6 +49,7 @@ app.get('/api/archives', (req, res) => {
|
|||||||
.map(item => {
|
.map(item => {
|
||||||
// Try to find a profile pic or first image for the thumbnail
|
// Try to find a profile pic or first image for the thumbnail
|
||||||
const archivePath = path.join(ARCHIVES_DIR, item.name);
|
const archivePath = path.join(ARCHIVES_DIR, item.name);
|
||||||
|
try {
|
||||||
const files = fs.readdirSync(archivePath);
|
const files = fs.readdirSync(archivePath);
|
||||||
console.log(`[API] Found archive: ${item.name} (${files.length} files)`);
|
console.log(`[API] Found archive: ${item.name} (${files.length} files)`);
|
||||||
|
|
||||||
@@ -61,13 +68,23 @@ app.get('/api/archives', (req, res) => {
|
|||||||
path: item.name,
|
path: item.name,
|
||||||
fileCount: files.length
|
fileCount: files.length
|
||||||
};
|
};
|
||||||
});
|
} catch (e) {
|
||||||
|
console.error(`[API] Could not read subdirectory ${item.name}:`, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
console.log(`[API] Returning ${archives.length} validated archives.`);
|
console.log(`[API] Returning ${archives.length} validated archives.`);
|
||||||
res.json(archives);
|
res.json(archives);
|
||||||
} catch (err) {
|
} catch (err: any) {
|
||||||
|
if (err.code === 'EACCES') {
|
||||||
|
console.error(`[API] Permission Denied! The server (UID ${os.userInfo().uid}) cannot read ${ARCHIVES_DIR}.`);
|
||||||
|
console.error(`[API] Hint: If using Linux/Docker, check folder permissions (chmod 755) or SELinux context (append :z to your volume mount).`);
|
||||||
|
} else {
|
||||||
console.error('[API] Error listing archives:', err);
|
console.error('[API] Error listing archives:', err);
|
||||||
res.status(500).json({ error: 'Failed to list archives' });
|
}
|
||||||
|
res.status(500).json({ error: 'Permission denied or failed to list archives' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user