new folder in webserver eith docker install webserver
This commit is contained in:
17
webserver/installDocker/Dockerfile
Normal file
17
webserver/installDocker/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Flutter Tank Web App - Deployment Dockerfile
|
||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
# Remove default nginx website
|
||||||
|
RUN rm -rf /usr/share/nginx/html/*
|
||||||
|
|
||||||
|
# Copy the built Flutter web app
|
||||||
|
COPY ../. /usr/share/nginx/html/
|
||||||
|
|
||||||
|
# Copy nginx configuration
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
# Expose port 80 (internally, mapped to 8888 externally)
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Start nginx
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
93
webserver/installDocker/README.md
Normal file
93
webserver/installDocker/README.md
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# Flutter Tank Web App - Docker Deployment
|
||||||
|
|
||||||
|
Dieser Ordner enthält alle notwendigen Dateien für das Docker-Deployment der Flutter Tank Web App.
|
||||||
|
|
||||||
|
## 📋 Voraussetzungen
|
||||||
|
|
||||||
|
- Docker muss auf dem Server installiert sein
|
||||||
|
- Port 8888 muss verfügbar sein
|
||||||
|
|
||||||
|
## 🚀 Deployment
|
||||||
|
|
||||||
|
### 1. Ordner auf Server kopieren
|
||||||
|
|
||||||
|
Kopieren Sie den kompletten `webserver` Ordner auf Ihren Server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scp -r webserver user@your-server:/path/to/destination/
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. In den installDocker Ordner wechseln
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /path/to/destination/webserver/installDocker
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Deployment ausführen
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./deploy.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Das Script führt automatisch folgende Schritte aus:
|
||||||
|
- Stoppt und entfernt bestehende Container
|
||||||
|
- Baut das Docker Image
|
||||||
|
- Startet den Container auf Port 8888
|
||||||
|
- Zeigt den Status an
|
||||||
|
|
||||||
|
## 🌐 Zugriff
|
||||||
|
|
||||||
|
Nach erfolgreichem Deployment ist die App erreichbar unter:
|
||||||
|
- **Web App:** `http://your-server:8888`
|
||||||
|
- **Health Check:** `http://your-server:8888/health`
|
||||||
|
|
||||||
|
## 🔧 Nützliche Befehle
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Logs anzeigen
|
||||||
|
docker logs flutter-tank-web-container
|
||||||
|
|
||||||
|
# Logs live verfolgen
|
||||||
|
docker logs -f flutter-tank-web-container
|
||||||
|
|
||||||
|
# Container stoppen
|
||||||
|
docker stop flutter-tank-web-container
|
||||||
|
|
||||||
|
# Container neustarten
|
||||||
|
docker restart flutter-tank-web-container
|
||||||
|
|
||||||
|
# Container und Image entfernen
|
||||||
|
docker stop flutter-tank-web-container
|
||||||
|
docker rm flutter-tank-web-container
|
||||||
|
docker rmi flutter-tank-web
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📁 Dateien
|
||||||
|
|
||||||
|
- **Dockerfile** - Docker Image Definition (nginx:alpine mit Flutter Web Build)
|
||||||
|
- **nginx.conf** - Nginx Konfiguration mit Gzip, Caching und Flutter Routing
|
||||||
|
- **deploy.sh** - Automatisches Deployment-Script
|
||||||
|
- **README.md** - Diese Dokumentation
|
||||||
|
|
||||||
|
## 🔒 Sicherheit
|
||||||
|
|
||||||
|
Die nginx.conf enthält bereits:
|
||||||
|
- Security Headers (X-Frame-Options, X-Content-Type-Options, X-XSS-Protection)
|
||||||
|
- Gzip Kompression für bessere Performance
|
||||||
|
- Caching für statische Assets (1 Jahr)
|
||||||
|
- Client-side Routing Support für Flutter
|
||||||
|
|
||||||
|
## 🐛 Troubleshooting
|
||||||
|
|
||||||
|
**Container startet nicht:**
|
||||||
|
```bash
|
||||||
|
docker logs flutter-tank-web-container
|
||||||
|
```
|
||||||
|
|
||||||
|
**Port bereits in Verwendung:**
|
||||||
|
Ändern Sie in `deploy.sh` die Variable `PORT=8888` auf einen anderen Port.
|
||||||
|
|
||||||
|
**Berechtigungsprobleme:**
|
||||||
|
```bash
|
||||||
|
chmod +x deploy.sh
|
||||||
|
```
|
||||||
66
webserver/installDocker/deploy.sh
Executable file
66
webserver/installDocker/deploy.sh
Executable file
@@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Flutter Tank Web App - Deployment Script
|
||||||
|
# This script builds and deploys the web app in a Docker container on port 8888
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
IMAGE_NAME="flutter-tank-web"
|
||||||
|
CONTAINER_NAME="flutter-tank-web-container"
|
||||||
|
PORT=8888
|
||||||
|
|
||||||
|
echo "🚀 Starting deployment of Flutter Tank Web App..."
|
||||||
|
echo "================================================"
|
||||||
|
|
||||||
|
# Stop and remove existing container if running
|
||||||
|
if [ "$(docker ps -q -f name=$CONTAINER_NAME)" ]; then
|
||||||
|
echo "⏹️ Stopping existing container..."
|
||||||
|
docker stop $CONTAINER_NAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$(docker ps -aq -f name=$CONTAINER_NAME)" ]; then
|
||||||
|
echo "🗑️ Removing existing container..."
|
||||||
|
docker rm $CONTAINER_NAME
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove old image (optional - comment out to keep old images)
|
||||||
|
if [ "$(docker images -q $IMAGE_NAME)" ]; then
|
||||||
|
echo "🗑️ Removing old image..."
|
||||||
|
docker rmi $IMAGE_NAME || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build new Docker image
|
||||||
|
echo "🔨 Building Docker image..."
|
||||||
|
docker build -t $IMAGE_NAME .
|
||||||
|
|
||||||
|
# Run container
|
||||||
|
echo "🚀 Starting container on port $PORT..."
|
||||||
|
docker run -d \
|
||||||
|
--name $CONTAINER_NAME \
|
||||||
|
-p $PORT:80 \
|
||||||
|
--restart unless-stopped \
|
||||||
|
$IMAGE_NAME
|
||||||
|
|
||||||
|
# Wait a moment for container to start
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
# Check if container is running
|
||||||
|
if [ "$(docker ps -q -f name=$CONTAINER_NAME)" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "✅ Deployment successful!"
|
||||||
|
echo "================================================"
|
||||||
|
echo "🌐 Application is running at: http://localhost:$PORT"
|
||||||
|
echo "🏥 Health check: http://localhost:$PORT/health"
|
||||||
|
echo ""
|
||||||
|
echo "Useful commands:"
|
||||||
|
echo " View logs: docker logs $CONTAINER_NAME"
|
||||||
|
echo " Follow logs: docker logs -f $CONTAINER_NAME"
|
||||||
|
echo " Stop: docker stop $CONTAINER_NAME"
|
||||||
|
echo " Restart: docker restart $CONTAINER_NAME"
|
||||||
|
echo "================================================"
|
||||||
|
else
|
||||||
|
echo "❌ Error: Container failed to start"
|
||||||
|
echo "Check logs with: docker logs $CONTAINER_NAME"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
35
webserver/installDocker/nginx.conf
Normal file
35
webserver/installDocker/nginx.conf
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# Compression
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_min_length 1024;
|
||||||
|
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript;
|
||||||
|
|
||||||
|
# Security headers
|
||||||
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||||
|
add_header X-Content-Type-Options "nosniff" always;
|
||||||
|
add_header X-XSS-Protection "1; mode=block" always;
|
||||||
|
|
||||||
|
# Cache static assets
|
||||||
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Flutter web routing - handle client-side routing
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Health check endpoint
|
||||||
|
location /health {
|
||||||
|
access_log off;
|
||||||
|
return 200 "healthy\n";
|
||||||
|
add_header Content-Type text/plain;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user