From 4218db49b51dcb8db2fee493d4c440752422e9c5 Mon Sep 17 00:00:00 2001 From: Simon Martens Date: Tue, 30 Sep 2025 12:21:57 +0200 Subject: [PATCH] deployment prep --- .dockerignore | 23 +++++++++++++++++++++++ .gitignore | 2 ++ docker-compose.yml | 2 +- kgpz_web.go | 11 ++++++++++- providers/config.go | 10 ++++++++++ scripts/generate_webp_originals.sh | 10 +++++----- scripts/generate_webp_previews.sh | 10 +++++----- views/assets/scripts.js | 2 +- views/layouts/components/_head.gohtml | 6 +++++- views/transform/places.js | 2 +- 10 files changed, 63 insertions(+), 15 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..22d09fd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +# Exclude pictures directory from Docker build context (21GB) +pictures/ + +# Exclude development files +*.dev.json +*.log +.git/ +.gitignore +README.md +*.md + +# Exclude build artifacts +node_modules/ +.npm/ +dist/ +build/ + +# Exclude IDE files +.vscode/ +.idea/ +*.swp +*.swo +*~ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 596c85d..42008e4 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,9 @@ cache_gnd/ data_bilder/ /pictures/ config.json +config.staging.json out.log kgpz_web *.log *.out +*.zip diff --git a/docker-compose.yml b/docker-compose.yml index 66467f6..0adea5d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: web: build: . volumes: - - kgpz_data:/app/data_git + - kgpz_data:/app/data ports: - "8000:8080" diff --git a/kgpz_web.go b/kgpz_web.go index dbff73c..10d6184 100644 --- a/kgpz_web.go +++ b/kgpz_web.go @@ -159,7 +159,16 @@ func Engine(kgpz *app.KGPZ, c *providers.ConfigProvider) *templating.Engine { timestamp := time.Now().Unix() // Add git commit information to global data - globals := fiber.Map{"isDev": c.Config.Debug, "name": "KGPZ", "lang": "de", "timestamp": timestamp} + isDev := c.Config.Environment == "development" + isStaging := c.Config.Environment == "staging" + globals := fiber.Map{ + "isDev": isDev, + "isStaging": isStaging, + "noIndex": c.Config.NoIndex, + "name": "KGPZ", + "lang": "de", + "timestamp": timestamp, + } if kgpz.Repo != nil { globals["gitCommit"] = kgpz.Repo.Commit globals["gitDate"] = kgpz.Repo.Date.Format("2006-01-02T15:04:05Z07:00") diff --git a/providers/config.go b/providers/config.go index 0f1176e..b76646d 100644 --- a/providers/config.go +++ b/providers/config.go @@ -50,6 +50,8 @@ type Config struct { Debug bool `json:"debug" envconfig:"DEBUG"` Watch bool `json:"watch" envconfig:"WATCH"` LogData bool `json:"log_data" envconfig:"LOG_DATA"` + Environment string `json:"environment" envconfig:"ENVIRONMENT"` + NoIndex bool `json:"no_index" envconfig:"NO_INDEX"` Address string `json:"address" envconfig:"ADDRESS"` Port string `json:"port" envconfig:"PORT"` @@ -140,6 +142,14 @@ func readDefaults(cfg *Config) *Config { cfg.PicturesPath = DEFAULT_PICTURES_DIR } + if strings.TrimSpace(cfg.Environment) == "" { + if cfg.Debug { + cfg.Environment = "development" + } else { + cfg.Environment = "production" + } + } + return cfg } diff --git a/scripts/generate_webp_originals.sh b/scripts/generate_webp_originals.sh index 1b7ee16..c07d366 100755 --- a/scripts/generate_webp_originals.sh +++ b/scripts/generate_webp_originals.sh @@ -13,9 +13,9 @@ BLUE='\033[0;34m' NC='\033[0m' # No Color # Configuration -QUALITY=95 # WebP quality (0-100) - very high for single page viewer -COMPRESSION=1 # WebP compression level (0-6, lower = less compression, higher quality) -PICTURES_DIR="pictures" +QUALITY=88 # WebP quality (0-100) - high quality with good compression +COMPRESSION=2 # WebP compression level (0-6, lower = less compression, higher quality) +PICTURES_DIR="/app/data/pictures" # Check if cwebp is installed if ! command -v cwebp &> /dev/null; then @@ -33,8 +33,8 @@ if [ ! -d "$PICTURES_DIR" ]; then fi echo -e "${BLUE}Generating high-quality WebP originals for single page viewer...${NC}" -echo "Quality: $QUALITY% (near-lossless)" -echo "Compression: $COMPRESSION (minimal compression for maximum quality)" +echo "Quality: $QUALITY% (high quality with compression)" +echo "Compression: $COMPRESSION (balanced compression for good quality)" echo "" # Counters diff --git a/scripts/generate_webp_previews.sh b/scripts/generate_webp_previews.sh index 42c561e..6849ce5 100755 --- a/scripts/generate_webp_previews.sh +++ b/scripts/generate_webp_previews.sh @@ -13,7 +13,7 @@ NC='\033[0m' # No Color # Configuration QUALITY=75 # WebP quality (0-100) COMPRESSION=6 # WebP compression level (0-6, higher = better compression) -PICTURES_DIR="pictures" +PICTURES_DIR="/app/data/pictures" # Check if cwebp is installed if ! command -v cwebp &> /dev/null; then @@ -42,7 +42,7 @@ fi echo -e "${GREEN}Generating WebP preview images...${NC}" echo "Quality: $QUALITY%" echo "Compression: $COMPRESSION" -echo "Resize: 50% (for faster loading)" +echo "Resize: 70% (for faster loading)" echo "" # Counters @@ -70,13 +70,13 @@ process_file() { echo -e "${YELLOW}Overriding existing preview: $webp_file${NC}" fi - # Get image dimensions and calculate 50% + # Get image dimensions and calculate 70% dimensions=$(identify -ping -format "%w %h" "$jpg_file" 2>/dev/null) if [ $? -eq 0 ] && [ -n "$dimensions" ]; then width=$(echo $dimensions | cut -d' ' -f1) height=$(echo $dimensions | cut -d' ' -f2) - new_width=$((width / 2)) - new_height=$((height / 2)) + new_width=$((width * 70 / 100)) + new_height=$((height * 70 / 100)) resize_params="-resize $new_width $new_height" echo "Processing: $jpg_file -> $webp_file (${width}x${height} → ${new_width}x${new_height})" else diff --git a/views/assets/scripts.js b/views/assets/scripts.js index 2db1951..cf268ab 100644 --- a/views/assets/scripts.js +++ b/views/assets/scripts.js @@ -875,7 +875,7 @@ class Y extends HTMLElement { })); } setPointActive(e) { - e.setAttribute("r", "0.8"), e.setAttribute("fill", "#dc2626"), e.setAttribute("stroke", "#b91c1c"), e.setAttribute("stroke-width", "0.12"), e.setAttribute("opacity", "1"), e.setAttribute("filter", "drop-shadow(0 0.05 0.1 rgba(0,0,0,0.2))"), e.parentNode && e.parentNode.appendChild(e); + e.setAttribute("r", "0.6"), e.setAttribute("fill", "#dc2626"), e.setAttribute("stroke", "#b91c1c"), e.setAttribute("stroke-width", "0.12"), e.setAttribute("opacity", "1"), e.setAttribute("filter", "drop-shadow(0 0.05 0.1 rgba(0,0,0,0.2))"), e.parentNode && e.parentNode.appendChild(e); } setPointInactive(e) { e.setAttribute("r", "0.4"), e.setAttribute("fill", "white"), e.setAttribute("stroke", "none"), e.setAttribute("opacity", "0.7"), e.setAttribute("filter", "drop-shadow(0 0.05 0.08 rgba(0,0,0,0.15))"); diff --git a/views/layouts/components/_head.gohtml b/views/layouts/components/_head.gohtml index 1cf122b..fbd9c24 100644 --- a/views/layouts/components/_head.gohtml +++ b/views/layouts/components/_head.gohtml @@ -1,10 +1,14 @@ +{{ if .noIndex }} + + +{{ end }} {{ block "head" . }} {{ end }} -{{ if .isDev }} +{{ if or .isDev .isStaging }} {{ else }} diff --git a/views/transform/places.js b/views/transform/places.js index 23c0a44..aff2d1c 100644 --- a/views/transform/places.js +++ b/views/transform/places.js @@ -623,7 +623,7 @@ export class PlacesMap extends HTMLElement { setPointActive(circle) { // Active state: darker red circle with wider dark border and small shadow - circle.setAttribute("r", "0.8"); // Bigger radius in % units + circle.setAttribute("r", "0.6"); // Bigger radius in % units circle.setAttribute("fill", "#dc2626"); circle.setAttribute("stroke", "#b91c1c"); circle.setAttribute("stroke-width", "0.12");