new ensure_dir logic
+ better logs + docker files + new docs
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
.*
|
.*
|
||||||
|
!.sh
|
||||||
!.gitignore
|
!.gitignore
|
||||||
output/
|
output/
|
||||||
__pycache__/
|
__pycache__/
|
42
Dockerfile
Normal file
42
Dockerfile
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
FROM python:3.11-alpine
|
||||||
|
|
||||||
|
RUN apk add --no-cache --virtual .build-deps \
|
||||||
|
build-base \
|
||||||
|
jpeg-dev \
|
||||||
|
zlib-dev \
|
||||||
|
libffi-dev \
|
||||||
|
musl-dev \
|
||||||
|
&& apk add --no-cache \
|
||||||
|
jpeg \
|
||||||
|
zlib \
|
||||||
|
libwebp \
|
||||||
|
bash
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt \
|
||||||
|
&& apk del .build-deps
|
||||||
|
|
||||||
|
RUN rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
|
# Copy source code and scripts
|
||||||
|
COPY ./src/ ./src/
|
||||||
|
COPY ./build.py ./build.py
|
||||||
|
COPY ./gallery.py ./gallery.py
|
||||||
|
|
||||||
|
# Copy default config
|
||||||
|
COPY ./config /app/default
|
||||||
|
|
||||||
|
# Copy entrypoint and make executable
|
||||||
|
COPY ./docker/.sh/entrypoint.sh /app/entrypoint.sh
|
||||||
|
RUN chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
|
# Add wrapper scripts for convenience commands
|
||||||
|
RUN printf '#!/bin/sh\n/app/entrypoint.sh build\n' > /usr/local/bin/build && chmod +x /usr/local/bin/build && \
|
||||||
|
printf '#!/bin/sh\n/app/entrypoint.sh gallery\n' > /usr/local/bin/gallery && chmod +x /usr/local/bin/gallery
|
||||||
|
|
||||||
|
|
||||||
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
|
|
29
README.MD
29
README.MD
@ -24,8 +24,7 @@ The project includes two thoughtfully designed themes—one modern, one minimali
|
|||||||
## 📌 Table of Contents
|
## 📌 Table of Contents
|
||||||
|
|
||||||
- [✨ Features](#-features)
|
- [✨ Features](#-features)
|
||||||
- [🐍 Python Installation](#-python-installation)
|
- [🐳 Docker or 🐍 Python Installation](#-docker-or--python-installation)
|
||||||
- [⚙️ Configuration](#-configuration)
|
|
||||||
|
|
||||||
|
|
||||||
## ✨ Features
|
## ✨ Features
|
||||||
@ -57,28 +56,6 @@ The project includes two thoughtfully designed themes—one modern, one minimali
|
|||||||
- *(Optional)* Converts images to WebP format for optimized performance
|
- *(Optional)* Converts images to WebP format for optimized performance
|
||||||
- Outputs a complete static website ready to deploy on any web server
|
- Outputs a complete static website ready to deploy on any web server
|
||||||
|
|
||||||
|
## 🐳 Docker or 🐍 Python Installation
|
||||||
## 🐍 Python Installation
|
For comprehensive documentation on installation, configuration options, customization, and demos, please visit:
|
||||||
|
|
||||||
Run the Python scripts directly with the following prerequisites:
|
|
||||||
|
|
||||||
### Prerequisites
|
|
||||||
|
|
||||||
- Git
|
|
||||||
- Python 3.11 or above
|
|
||||||
|
|
||||||
### Installation Steps
|
|
||||||
|
|
||||||
```sh
|
|
||||||
git clone https://git.djeex.fr/Djeex/lumeex.git
|
|
||||||
cd lumeex
|
|
||||||
python3 -m venv .venv
|
|
||||||
source .venv/bin/activate
|
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
You are now ready to use Lumeex!
|
|
||||||
|
|
||||||
## ⚙️ Configuration
|
|
||||||
For comprehensive documentation on configuration options, customization, and demos, please visit:
|
|
||||||
https://lumeex.djeex.fr
|
https://lumeex.djeex.fr
|
73
docker/.sh/entrypoint.sh
Normal file
73
docker/.sh/entrypoint.sh
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
CYAN="\033[1;36m"
|
||||||
|
NC="\033[0m"
|
||||||
|
|
||||||
|
copy_default_config() {
|
||||||
|
echo "Checking configuration directory..."
|
||||||
|
if [ ! -d "/app/config" ]; then
|
||||||
|
mkdir -p /app/config
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Checking if default config files need to be copied..."
|
||||||
|
files_copied=false
|
||||||
|
|
||||||
|
for file in /app/default/*; do
|
||||||
|
filename=$(basename "$file")
|
||||||
|
target="/app/config/$filename"
|
||||||
|
|
||||||
|
if [ ! -e "$target" ]; then
|
||||||
|
echo "Copying default config file: $filename"
|
||||||
|
cp "$file" "$target"
|
||||||
|
files_copied=true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$files_copied" = true ]; then
|
||||||
|
echo "Default configuration files copied successfully."
|
||||||
|
else
|
||||||
|
echo "No default files needed to be copied."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
start_server() {
|
||||||
|
mkfifo /tmp/build_logs_fifo
|
||||||
|
mkfifo /tmp/build_logs_fifo2
|
||||||
|
cat /tmp/build_logs_fifo >&2 &
|
||||||
|
cat /tmp/build_logs_fifo2 >&2 &
|
||||||
|
echo "Starting HTTP server on port 3000..."
|
||||||
|
python3 -u -m http.server 3000 -d /app/output &
|
||||||
|
SERVER_PID=$!
|
||||||
|
trap "echo 'Stopping server...'; kill -TERM $SERVER_PID 2>/dev/null; wait $SERVER_PID; exit 0" SIGINT SIGTERM
|
||||||
|
wait $SERVER_PID
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo -e "${CYAN}╭───────────────────────────────────────────╮${NC}"
|
||||||
|
echo -e "${CYAN}│${NC} Lum${CYAN}eex${NC} - Version 1.3${NC} ${CYAN}│${NC}"
|
||||||
|
echo -e "${CYAN}├───────────────────────────────────────────┤${NC}"
|
||||||
|
echo -e "${CYAN}│${NC} Source: https://git.djeex.fr/Djeex/lumeex ${CYAN}│${NC}"
|
||||||
|
echo -e "${CYAN}│${NC} Mirror: https://github.com/Djeex/lumeex ${CYAN}│${NC}"
|
||||||
|
echo -e "${CYAN}│${NC} Documentation: https://lumeex.djeex.fr ${CYAN}│${NC}"
|
||||||
|
echo -e "${CYAN}╰───────────────────────────────────────────╯${NC}"
|
||||||
|
copy_default_config
|
||||||
|
start_server
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
build)
|
||||||
|
echo "Running build.py..."
|
||||||
|
python3 -u /app/build.py 2>&1 | tee /tmp/build_logs_fifo
|
||||||
|
;;
|
||||||
|
gallery)
|
||||||
|
echo "Running gallery.py..."
|
||||||
|
python3 -u /app/gallery.py 2>&1 | tee /tmp/build_logs_fifo2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown command: $1"
|
||||||
|
exec "$@"
|
||||||
|
;;
|
||||||
|
esac
|
10
docker/docker-compose.yaml
Normal file
10
docker/docker-compose.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
services:
|
||||||
|
lumeex:
|
||||||
|
container_name: lmx
|
||||||
|
build: ..
|
||||||
|
volumes:
|
||||||
|
- ../config:/app/config # mount config directory
|
||||||
|
- ../output:/app/output # mount output directory
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
|
@ -23,7 +23,12 @@ SITE_FILE = SRC_DIR / "config/site.yaml"
|
|||||||
THEMES_DIR = SRC_DIR / "config/themes"
|
THEMES_DIR = SRC_DIR / "config/themes"
|
||||||
|
|
||||||
def build():
|
def build():
|
||||||
logging.info("🚀 Starting build...")
|
build_version = "v1.3"
|
||||||
|
logging.info("\n")
|
||||||
|
logging.info("=" * 23)
|
||||||
|
logging.info(f"🚀 Lumeex builder {build_version}")
|
||||||
|
logging.info("=" * 23)
|
||||||
|
logging.info("\n === Starting build === ")
|
||||||
ensure_dir(BUILD_DIR)
|
ensure_dir(BUILD_DIR)
|
||||||
copy_assets(JS_DIR, STYLE_DIR, BUILD_DIR)
|
copy_assets(JS_DIR, STYLE_DIR, BUILD_DIR)
|
||||||
|
|
||||||
@ -87,7 +92,7 @@ def build():
|
|||||||
|
|
||||||
# Adding Google fonts if existing
|
# Adding Google fonts if existing
|
||||||
google_fonts_link = generate_google_fonts_link(theme_vars.get("google_fonts", []))
|
google_fonts_link = generate_google_fonts_link(theme_vars.get("google_fonts", []))
|
||||||
logging.info(f"[✓] Google Fonts link generated:\n{google_fonts_link}")
|
logging.info(f"[✓] Google Fonts link generated")
|
||||||
|
|
||||||
# Generating thumbnail
|
# Generating thumbnail
|
||||||
thumbnail_path = site_vars.get("social", {}).get("thumbnail")
|
thumbnail_path = site_vars.get("social", {}).get("thumbnail")
|
||||||
@ -125,7 +130,7 @@ def build():
|
|||||||
gallery_html = render_gallery_images(gallery_images)
|
gallery_html = render_gallery_images(gallery_images)
|
||||||
gallery = render_template(TEMPLATE_DIR / "gallery.html", {"gallery_images": gallery_html})
|
gallery = render_template(TEMPLATE_DIR / "gallery.html", {"gallery_images": gallery_html})
|
||||||
|
|
||||||
signature = f"<!-- Build with Lumeex v1.2 | https://git.djeex.fr/Djeex/lumeex | {build_date_version} -->"
|
signature = f"<!-- Build with Lumeex {build_version} | https://git.djeex.fr/Djeex/lumeex | {build_date_version} -->"
|
||||||
body = f"""
|
body = f"""
|
||||||
<body>
|
<body>
|
||||||
<div class="page-loader"><div class="spinner"></div></div>
|
<div class="page-loader"><div class="spinner"></div></div>
|
||||||
|
@ -19,10 +19,25 @@ def load_theme_config(theme_name, themes_dir):
|
|||||||
theme_vars = yaml.safe_load(f)
|
theme_vars = yaml.safe_load(f)
|
||||||
return theme_vars, theme_dir
|
return theme_vars, theme_dir
|
||||||
|
|
||||||
def ensure_dir(path):
|
def clear_dir(path: Path):
|
||||||
if path.exists():
|
if not path.exists():
|
||||||
rmtree(path)
|
|
||||||
path.mkdir(parents=True)
|
path.mkdir(parents=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
# Remove all files and subdirectories inside path, but not path itself
|
||||||
|
for child in path.iterdir():
|
||||||
|
if child.is_file() or child.is_symlink():
|
||||||
|
child.unlink() # delete file or symlink
|
||||||
|
elif child.is_dir():
|
||||||
|
rmtree(child) # delete directory and contents
|
||||||
|
|
||||||
|
# Then replace your ensure_dir with this:
|
||||||
|
|
||||||
|
def ensure_dir(path: Path):
|
||||||
|
if not path.exists():
|
||||||
|
path.mkdir(parents=True)
|
||||||
|
else:
|
||||||
|
clear_dir(path)
|
||||||
|
|
||||||
def copy_assets(js_dir, style_dir, build_dir):
|
def copy_assets(js_dir, style_dir, build_dir):
|
||||||
for folder in [js_dir, style_dir]:
|
for folder in [js_dir, style_dir]:
|
||||||
|
Reference in New Issue
Block a user