nigga
This commit is contained in:
parent
704372d29a
commit
85570c024b
42
Dockerfile
42
Dockerfile
|
|
@ -1,34 +1,32 @@
|
||||||
# Build
|
# Utilise Ubuntu 24.04 pour avoir des bibliothèques systèmes à jour
|
||||||
FROM rust:1.75-slim AS builder
|
FROM rust:latest AS builder
|
||||||
|
# (Rust 1.78 est très récent et gère parfaitement le format lock v4)
|
||||||
# Dependencies
|
RUN apt-get update && apt-get install -y cmake nasm clang libssl-dev pkg-config
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
cmake \
|
|
||||||
nasm \
|
|
||||||
clang \
|
|
||||||
pkg-config \
|
|
||||||
libssl-dev \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Compile for prod
|
|
||||||
RUN cargo build --release --bin scrape
|
RUN cargo build --release --bin scrape
|
||||||
|
|
||||||
# Lightweight image
|
FROM ubuntu:24.04
|
||||||
FROM debian:bookworm-slim
|
# Installation des dépendances nécessaires
|
||||||
|
|
||||||
# Runtime libs
|
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
libssl3 \
|
libssl3 \
|
||||||
|
python3 \
|
||||||
|
git \
|
||||||
|
ssh \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy binary to bin folder
|
|
||||||
COPY --from=builder /app/target/release/scrape /usr/local/bin/scrape
|
COPY --from=builder /app/target/release/scrape /usr/local/bin/scrape
|
||||||
|
COPY generate_readme.py /app/generate_readme.py
|
||||||
|
|
||||||
# Run scraping
|
RUN echo '#!/bin/sh\n\
|
||||||
CMD ["scrape"]
|
git config --global user.email "bot@periodicbrake.fr"\n\
|
||||||
|
git config --global user.name "Wallpaper Bot"\n\
|
||||||
|
/usr/local/bin/scrape\n\
|
||||||
|
python3 /app/generate_readme.py\n\
|
||||||
|
git add README*.md assets/*.json\n\
|
||||||
|
git diff --exit-code > /dev/null || (git commit -m "chore: auto-update" && git push)\n\
|
||||||
|
' > /app/run.sh && chmod +x /app/run.sh
|
||||||
|
|
||||||
|
CMD ["/app/run.sh"]
|
||||||
|
|
|
||||||
36
generate_readme.py
Normal file
36
generate_readme.py
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
import glob
|
||||||
|
|
||||||
|
# Your Nginx domain
|
||||||
|
CDN_BASE = "https://colorwall-repo.periodicbrake.fr"
|
||||||
|
|
||||||
|
header = "# Wallpaper Archive\n\nAutomated archive of wallpapers.\n\n## Gallery\n\n| Preview | Title | Tags |\n| --- | --- | --- |\n"
|
||||||
|
rows = []
|
||||||
|
|
||||||
|
# Scans the mapped /app/assets folder
|
||||||
|
for json_file in sorted(glob.glob("assets/*.json")):
|
||||||
|
try:
|
||||||
|
with open(json_file, "r", encoding="utf-8") as f:
|
||||||
|
item = json.load(f)
|
||||||
|
|
||||||
|
item_id = item.get("id", "unknown")
|
||||||
|
title = item.get("title", "Wallpaper")
|
||||||
|
tags = ", ".join(item.get("tags", []))
|
||||||
|
|
||||||
|
# Assuming files are named <id>.png or <id>.jpg in the same folder
|
||||||
|
ext = "png" if ".png" in item.get("download_url", "").lower() else "jpg"
|
||||||
|
filename = f"{item_id}.{ext}"
|
||||||
|
cdn_url = f"{CDN_BASE}/{filename}"
|
||||||
|
|
||||||
|
row = f'| <img src="{cdn_url}" width="200"> | **{title}**<br>[Download]({cdn_url}) | {tags} |\n'
|
||||||
|
rows.append((item_id, row))
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Skipping {json_file}: {e}")
|
||||||
|
|
||||||
|
with open("README.md", "w", encoding="utf-8") as f:
|
||||||
|
f.write(header)
|
||||||
|
for _, row in rows:
|
||||||
|
f.write(row)
|
||||||
|
|
||||||
|
print("README.md has been successfully generated.")
|
||||||
Loading…
Reference in a new issue