diff options
| author | diogo464 <[email protected]> | 2025-08-14 14:46:47 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-08-14 14:46:47 +0100 |
| commit | 5c32d58bbeb6d0cc836a78a2279bb88ffc8fba63 (patch) | |
| tree | 225395773dc1573fc5148a6795a80f0f22007568 | |
| parent | cf290372162b918c56d2c2e5ba67d7f448ad19ba (diff) | |
add: container configuration files
- .containerignore: exclude unnecessary files from container builds
- CONTAINER.md: documentation for container deployment
- Containerfile: multi-stage build configuration for production
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
| -rw-r--r-- | .containerignore | 46 | ||||
| -rw-r--r-- | CONTAINER.md | 76 | ||||
| -rw-r--r-- | Containerfile | 34 |
3 files changed, 156 insertions, 0 deletions
diff --git a/.containerignore b/.containerignore new file mode 100644 index 0000000..7890d39 --- /dev/null +++ b/.containerignore | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | # Rust build artifacts (except the final binary) | ||
| 2 | target/debug/ | ||
| 3 | target/*/incremental/ | ||
| 4 | target/*/deps/ | ||
| 5 | target/*/.fingerprint/ | ||
| 6 | target/*/build/ | ||
| 7 | target/doc/ | ||
| 8 | target/package/ | ||
| 9 | target/publish/ | ||
| 10 | target/install/ | ||
| 11 | |||
| 12 | # Rust source (not needed in container) | ||
| 13 | src/ | ||
| 14 | Cargo.toml | ||
| 15 | Cargo.lock | ||
| 16 | |||
| 17 | # Git | ||
| 18 | .git/ | ||
| 19 | .gitignore | ||
| 20 | |||
| 21 | # IDE | ||
| 22 | .vscode/ | ||
| 23 | .idea/ | ||
| 24 | |||
| 25 | # OS | ||
| 26 | .DS_Store | ||
| 27 | Thumbs.db | ||
| 28 | |||
| 29 | # Frontend dev dependencies | ||
| 30 | frontend/node_modules/ | ||
| 31 | frontend/.turbo/ | ||
| 32 | |||
| 33 | # Logs | ||
| 34 | *.log | ||
| 35 | log.txt | ||
| 36 | |||
| 37 | # Blob storage (should be mounted as volume) | ||
| 38 | blobs/ | ||
| 39 | miei/ | ||
| 40 | |||
| 41 | # Development files | ||
| 42 | tinyauth.sh | ||
| 43 | flamegraph.svg | ||
| 44 | write.lock | ||
| 45 | README.md | ||
| 46 | CLAUDE.md \ No newline at end of file | ||
diff --git a/CONTAINER.md b/CONTAINER.md new file mode 100644 index 0000000..b87d65d --- /dev/null +++ b/CONTAINER.md | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | # FCTDrive Container Deployment | ||
| 2 | |||
| 3 | This document explains how to build and run the FCTDrive application as a container. | ||
| 4 | |||
| 5 | ## Prerequisites | ||
| 6 | |||
| 7 | 1. **Build the binaries locally first:** | ||
| 8 | ```bash | ||
| 9 | # Build the Rust CLI tool | ||
| 10 | just build # or: cargo build --release --target-dir target/ | ||
| 11 | |||
| 12 | # Build the frontend (optional, done in container) | ||
| 13 | cd frontend && npm run build | ||
| 14 | ``` | ||
| 15 | |||
| 16 | 2. **Container runtime** (podman, docker, etc.) | ||
| 17 | |||
| 18 | ## Building the Container | ||
| 19 | |||
| 20 | ```bash | ||
| 21 | # Build the container image | ||
| 22 | podman build -t fctdrive:latest . | ||
| 23 | |||
| 24 | # Or with docker | ||
| 25 | docker build -t fctdrive:latest . | ||
| 26 | ``` | ||
| 27 | |||
| 28 | ## Running the Container | ||
| 29 | |||
| 30 | ```bash | ||
| 31 | # Run with volumes for persistent data | ||
| 32 | podman run -d \ | ||
| 33 | --name fctdrive \ | ||
| 34 | -p 3000:3000 \ | ||
| 35 | -v ./blobs:/app/blobs:Z \ | ||
| 36 | -v ./data:/app/data:Z \ | ||
| 37 | -e TINYAUTH_ENDPOINT=http://localhost:3001 \ | ||
| 38 | -e TINYAUTH_PUBLIC_ENDPOINT=http://localhost:3001 \ | ||
| 39 | -e FCTDRIVE_PATH=/app/data \ | ||
| 40 | fctdrive:latest | ||
| 41 | ``` | ||
| 42 | |||
| 43 | ## Environment Variables | ||
| 44 | |||
| 45 | - `TINYAUTH_ENDPOINT` - Internal TinyAuth server URL | ||
| 46 | - `TINYAUTH_PUBLIC_ENDPOINT` - Public TinyAuth server URL (for browser redirects) | ||
| 47 | - `FCTDRIVE_PATH` - Path to the drive data directory | ||
| 48 | - `NODE_ENV=production` (set automatically) | ||
| 49 | - `HOSTNAME=0.0.0.0` (set automatically) | ||
| 50 | |||
| 51 | ## Volume Mounts | ||
| 52 | |||
| 53 | - `/app/blobs` - Blob storage directory | ||
| 54 | - `/app/data` - Drive metadata/database directory | ||
| 55 | |||
| 56 | ## Container Features | ||
| 57 | |||
| 58 | - **Base image**: Fedora 42 | ||
| 59 | - **Runtime**: Node.js + npm | ||
| 60 | - **Binary**: Pre-built `fctdrive` binary in PATH | ||
| 61 | - **User**: Non-root user `fctdrive` | ||
| 62 | - **Port**: 3000 (Next.js server) | ||
| 63 | - **Build**: Production Next.js build | ||
| 64 | |||
| 65 | ## Security | ||
| 66 | |||
| 67 | - Runs as non-root user (`fctdrive:fctdrive`) | ||
| 68 | - Only production dependencies installed | ||
| 69 | - Minimal attack surface with focused .containerignore | ||
| 70 | |||
| 71 | ## Development vs Production | ||
| 72 | |||
| 73 | This container is designed for production deployment. For development: | ||
| 74 | - Use `just dev` for hot-reloading | ||
| 75 | - Mount source code as volumes | ||
| 76 | - Use development dependencies \ No newline at end of file | ||
diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..45b52a9 --- /dev/null +++ b/Containerfile | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | FROM fedora:42 | ||
| 2 | |||
| 3 | # Install Node.js and npm | ||
| 4 | RUN dnf install -y nodejs npm && \ | ||
| 5 | dnf clean all | ||
| 6 | |||
| 7 | # Create app directory | ||
| 8 | WORKDIR /app | ||
| 9 | |||
| 10 | # Copy package files and install production dependencies only | ||
| 11 | COPY frontend/package*.json ./ | ||
| 12 | RUN npm ci --only=production && \ | ||
| 13 | npm cache clean --force | ||
| 14 | |||
| 15 | # Copy the pre-built Next.js application | ||
| 16 | COPY frontend/.next ./.next | ||
| 17 | COPY frontend/public ./public | ||
| 18 | COPY frontend/next.config.ts ./ | ||
| 19 | COPY frontend/package.json ./ | ||
| 20 | |||
| 21 | |||
| 22 | # Copy the built fctdrive binary to PATH | ||
| 23 | COPY target/release/fctdrive /usr/local/bin/fctdrive | ||
| 24 | RUN chmod +x /usr/local/bin/fctdrive | ||
| 25 | |||
| 26 | # Expose port | ||
| 27 | EXPOSE 3000 | ||
| 28 | |||
| 29 | # Set environment variables | ||
| 30 | ENV NODE_ENV=production | ||
| 31 | ENV HOSTNAME=0.0.0.0 | ||
| 32 | |||
| 33 | # Start the Next.js server | ||
| 34 | CMD ["npm", "start"] | ||
