summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.containerignore46
-rw-r--r--CONTAINER.md76
-rw-r--r--Containerfile34
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)
2target/debug/
3target/*/incremental/
4target/*/deps/
5target/*/.fingerprint/
6target/*/build/
7target/doc/
8target/package/
9target/publish/
10target/install/
11
12# Rust source (not needed in container)
13src/
14Cargo.toml
15Cargo.lock
16
17# Git
18.git/
19.gitignore
20
21# IDE
22.vscode/
23.idea/
24
25# OS
26.DS_Store
27Thumbs.db
28
29# Frontend dev dependencies
30frontend/node_modules/
31frontend/.turbo/
32
33# Logs
34*.log
35log.txt
36
37# Blob storage (should be mounted as volume)
38blobs/
39miei/
40
41# Development files
42tinyauth.sh
43flamegraph.svg
44write.lock
45README.md
46CLAUDE.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
3This document explains how to build and run the FCTDrive application as a container.
4
5## Prerequisites
6
71. **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
162. **Container runtime** (podman, docker, etc.)
17
18## Building the Container
19
20```bash
21# Build the container image
22podman build -t fctdrive:latest .
23
24# Or with docker
25docker build -t fctdrive:latest .
26```
27
28## Running the Container
29
30```bash
31# Run with volumes for persistent data
32podman 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
73This 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 @@
1FROM fedora:42
2
3# Install Node.js and npm
4RUN dnf install -y nodejs npm && \
5 dnf clean all
6
7# Create app directory
8WORKDIR /app
9
10# Copy package files and install production dependencies only
11COPY frontend/package*.json ./
12RUN npm ci --only=production && \
13 npm cache clean --force
14
15# Copy the pre-built Next.js application
16COPY frontend/.next ./.next
17COPY frontend/public ./public
18COPY frontend/next.config.ts ./
19COPY frontend/package.json ./
20
21
22# Copy the built fctdrive binary to PATH
23COPY target/release/fctdrive /usr/local/bin/fctdrive
24RUN chmod +x /usr/local/bin/fctdrive
25
26# Expose port
27EXPOSE 3000
28
29# Set environment variables
30ENV NODE_ENV=production
31ENV HOSTNAME=0.0.0.0
32
33# Start the Next.js server
34CMD ["npm", "start"]