diff --git a/.gitignore b/.gitignore index 8fb0456..7adc878 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .* +!.sh !.gitignore output/ __pycache__/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d9e0b5a --- /dev/null +++ b/Dockerfile @@ -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"] + diff --git a/README.MD b/README.MD index 1da9f46..7a92e40 100644 --- a/README.MD +++ b/README.MD @@ -23,9 +23,8 @@ The project includes two thoughtfully designed themesโone modern, one minimali ## ๐ Table of Contents -- [โจ Features](#-features) -- [๐ Python Installation](#-python-installation) -- [โ๏ธ Configuration](#-configuration) +- [โจ Features](#-features) +- [๐ณ Docker or ๐ Python Installation](#-docker-or--python-installation) ## โจ 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 - Outputs a complete static website ready to deploy on any web server - -## ๐ Python Installation - -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: +## ๐ณ Docker or ๐ Python Installation +For comprehensive documentation on installation, configuration options, customization, and demos, please visit: https://lumeex.djeex.fr \ No newline at end of file diff --git a/docker/.sh/entrypoint.sh b/docker/.sh/entrypoint.sh new file mode 100644 index 0000000..22da5c5 --- /dev/null +++ b/docker/.sh/entrypoint.sh @@ -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 diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml new file mode 100644 index 0000000..aab8432 --- /dev/null +++ b/docker/docker-compose.yaml @@ -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" + \ No newline at end of file diff --git a/src/py/site_builder.py b/src/py/site_builder.py index 45da59d..0b55287 100644 --- a/src/py/site_builder.py +++ b/src/py/site_builder.py @@ -23,7 +23,12 @@ SITE_FILE = SRC_DIR / "config/site.yaml" THEMES_DIR = SRC_DIR / "config/themes" 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) copy_assets(JS_DIR, STYLE_DIR, BUILD_DIR) @@ -87,7 +92,7 @@ def build(): # Adding Google fonts if existing 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 thumbnail_path = site_vars.get("social", {}).get("thumbnail") @@ -125,7 +130,7 @@ def build(): gallery_html = render_gallery_images(gallery_images) gallery = render_template(TEMPLATE_DIR / "gallery.html", {"gallery_images": gallery_html}) - signature = f"" + signature = f"" body = f"""