This commit is contained in:
2025-07-29 00:58:18 +01:00
parent daa92c4c41
commit 891e398882
9 changed files with 363 additions and 1 deletions

21
.dockerignore Normal file
View File

@@ -0,0 +1,21 @@
# AAF Systems Homepage - Docker
# Dockerfile
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Development files
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
# IDE files
.vscode/
.idea/
# Build output (will be created inside container)
dist/

26
Dockerfile Normal file
View File

@@ -0,0 +1,26 @@
# Use Node.js 18 alpine as base image for smaller size
FROM node:18-alpine
# Set working directory
WORKDIR /app
# Copy package files
COPY app/package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY app/ .
# Build the application
RUN npm run build
# Install a simple HTTP server to serve the built files
RUN npm install -g serve
# Expose port 8080
EXPOSE 8080
# Start the application on port 8080
CMD ["serve", "-s", "dist", "-l", "8080"]

126
README.md
View File

@@ -1,2 +1,126 @@
# aaf-systems-homepage
# AAF Systems Homepage
A modern 3D homepage built with Three.js, TypeScript, and Vite.
## Features
- 3D graphics with Three.js
- Physics simulation with Cannon.js
- Post-processing effects
- TypeScript for type safety
- Hot reload development with Vite
## Docker Setup
### Prerequisites
- Docker
- Docker Compose (optional)
### Running with Docker
#### Option 1: Using Docker Compose (Recommended)
```bash
# Build and run the application
docker-compose up --build
# Run in detached mode
docker-compose up -d --build
# Stop the application
docker-compose down
```
#### Option 2: Using Docker directly
```bash
# Build the Docker image
docker build -t aaf-systems-homepage .
# Run the container
docker run -p 8080:8080 aaf-systems-homepage
```
The application will be available at `http://localhost:8080`
## Local Development
### Prerequisites
- Node.js 18+
- npm
### Setup
```bash
cd app
npm install
npm run dev
```
The development server will start at `http://localhost:5173`
### Build for Production
```bash
cd app
npm run build
npm run preview
```
## Project Structure
- `app/` - Main application directory
- `src/` - TypeScript source code
- `public/` - Static assets
- `index.html` - Entry point
- `Dockerfile` - Docker configuration
- `docker-compose.yml` - Docker Compose configuration
## Docker Packaging & Transfer
### Package Image for Transfer
To package the Docker image for transfer to another computer:
```bash
# Build and package the Docker image
./package-docker.sh
```
This will create a `aaf-systems-homepage-docker.tar` file that you can transfer to another computer.
### Transfer Methods
**Option 1: USB/External Drive**
```bash
# Copy the .tar file to USB drive
cp aaf-systems-homepage-docker.tar /path/to/usb/drive/
```
**Option 2: Network Transfer (SCP)**
```bash
# Transfer via SCP
scp aaf-systems-homepage-docker.tar user@target-computer:/path/to/destination/
```
**Option 3: Cloud Storage**
Upload `aaf-systems-homepage-docker.tar` to your preferred cloud storage service.
### Load and Run on Target Computer
On the target computer:
1. Make sure Docker is installed and running
2. Copy both files to the target computer:
- `aaf-systems-homepage-docker.tar` (the image package)
- `load-and-run-docker.sh` (the load script)
3. Run the load script:
```bash
# Load and run the Docker image
./load-and-run-docker.sh
```
The application will be available at `http://localhost:8080` on the target computer.

23
app/vite.config.ts Normal file
View File

@@ -0,0 +1,23 @@
import { defineConfig } from 'vite'
export default defineConfig({
base: './',
build: {
outDir: 'dist',
assetsDir: 'assets',
sourcemap: false,
rollupOptions: {
output: {
manualChunks: undefined,
},
},
},
server: {
host: '0.0.0.0',
port: 8080,
},
preview: {
host: '0.0.0.0',
port: 8080,
},
})

10
docker-compose.yml Normal file
View File

@@ -0,0 +1,10 @@
version: '3.8'
services:
aaf-systems-homepage:
build: .
ports:
- "8080:8080"
environment:
- NODE_ENV=production
restart: unless-stopped

55
load-and-run-docker.sh Executable file
View File

@@ -0,0 +1,55 @@
#!/bin/bash
# AAF Systems Homepage - Docker Load Script
# This script loads and runs a packaged Docker image on the target computer
echo "🚀 AAF Systems Homepage Docker Load & Run"
echo "========================================="
IMAGE_NAME="aaf-systems-homepage"
PACKAGE_NAME="aaf-systems-homepage-docker.tar"
CONTAINER_NAME="aaf-systems-homepage"
# Check if Docker is running
if ! sudo docker info > /dev/null 2>&1; then
echo "❌ Docker is not running. Please start Docker and try again."
exit 1
fi
# Check if package file exists
if [ ! -f "$PACKAGE_NAME" ]; then
echo "❌ Package file '$PACKAGE_NAME' not found in current directory"
echo "Please make sure the .tar file is in the same directory as this script"
exit 1
fi
echo "📦 Loading Docker image from $PACKAGE_NAME..."
sudo docker load -i $PACKAGE_NAME
if [ $? -ne 0 ]; then
echo "❌ Failed to load Docker image"
exit 1
fi
echo "🛑 Stopping any existing container..."
sudo docker stop $CONTAINER_NAME 2>/dev/null || true
sudo docker rm $CONTAINER_NAME 2>/dev/null || true
echo "🚀 Starting container on port 8080..."
sudo docker run -d -p 8080:8080 --name $CONTAINER_NAME $IMAGE_NAME
if [ $? -eq 0 ]; then
echo "✅ Container started successfully!"
echo ""
echo "🌐 Application is running at: http://localhost:8080"
echo ""
echo "📋 Useful Commands:"
echo "=================="
echo "View logs: sudo docker logs $CONTAINER_NAME"
echo "Stop container: sudo docker stop $CONTAINER_NAME"
echo "Remove container: sudo docker rm $CONTAINER_NAME"
echo "Check status: sudo docker ps"
else
echo "❌ Failed to start container"
exit 1
fi

46
package-docker.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/bash
# AAF Systems Homepage - Docker Package Script
# This script builds and packages the Docker image for transfer to another computer
echo "📦 AAF Systems Homepage Docker Packaging"
echo "========================================"
IMAGE_NAME="aaf-systems-homepage"
PACKAGE_NAME="aaf-systems-homepage-docker.tar"
# Check if Docker is running
if ! sudo docker info > /dev/null 2>&1; then
echo "❌ Docker is not running. Please start Docker and try again."
exit 1
fi
echo "🔨 Building Docker image..."
sudo docker build -t $IMAGE_NAME .
if [ $? -ne 0 ]; then
echo "❌ Failed to build Docker image"
exit 1
fi
echo "📦 Packaging Docker image to $PACKAGE_NAME..."
sudo docker save -o $PACKAGE_NAME $IMAGE_NAME
if [ $? -eq 0 ]; then
echo "✅ Docker image packaged successfully!"
echo ""
echo "📋 Transfer Instructions:"
echo "========================"
echo "1. Copy '$PACKAGE_NAME' to the target computer"
echo "2. On the target computer, run:"
echo " sudo docker load -i $PACKAGE_NAME"
echo "3. Run the container:"
echo " sudo docker run -p 8080:8080 --name aaf-systems-homepage $IMAGE_NAME"
echo ""
echo "📊 Package Info:"
echo "==============="
ls -lh $PACKAGE_NAME
else
echo "❌ Failed to package Docker image"
exit 1
fi

36
run-docker.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
# AAF Systems Homepage - Docker Runner Script
echo "🚀 AAF Systems Homepage Docker Setup"
echo "===================================="
# Check if Docker is running
if ! sudo docker info > /dev/null 2>&1; then
echo "❌ Docker is not running. Please start Docker Desktop and try again."
exit 1
fi
# Function to build and run with Docker Compose
run_with_compose() {
echo "🔨 Building and running with Docker Compose..."
sudo docker-compose up --build
}
# Function to build and run with Docker directly
run_with_docker() {
echo "🔨 Building Docker image..."
sudo docker build -t aaf-systems-homepage .
echo "🚀 Running container on port 8080..."
sudo docker run -p 8080:8080 --name aaf-systems-homepage aaf-systems-homepage
}
# Check if docker-compose is available
if command -v docker-compose &> /dev/null; then
echo "📋 Docker Compose detected. Using docker-compose.yml..."
run_with_compose
else
echo "📋 Docker Compose not found. Using Docker directly..."
run_with_docker
fi

21
stop-docker.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# AAF Systems Homepage - Docker Stop Script
echo "🛑 Stopping AAF Systems Homepage Docker Container"
echo "================================================"
# Stop and remove the container
echo "🔍 Stopping container..."
sudo docker stop aaf-systems-homepage 2>/dev/null || echo "Container not running"
echo "🗑️ Removing container..."
sudo docker rm aaf-systems-homepage 2>/dev/null || echo "Container not found"
# If using docker-compose, stop that too
if command -v docker-compose &> /dev/null; then
echo "🔍 Stopping docker-compose services..."
sudo docker-compose down 2>/dev/null || echo "No docker-compose services running"
fi
echo "✅ Cleanup complete!"