FROM rust:1.92-alpine AS builder WORKDIR /build RUN apk add --no-cache musl-dev openssl-dev pkgconfig COPY Cargo.toml Cargo.lock build.rs Cargo_no_official.toml ./ COPY src/ src/ COPY .cargo/ .cargo/ COPY fake_error.html ./ COPY img/ img/ RUN mkdir -p /Tomato-Novel-Official-API/src && \ printf '[package]\nname = "tomato-novel-official-api"\nversion = "0.1.0"\nedition = "2021"\n' > /Tomato-Novel-Official-API/Cargo.toml && \ touch /Tomato-Novel-Official-API/src/lib.rs RUN cargo build --release --no-default-features --features "telegram,no-official-api" FROM alpine:3.21 RUN apk add --no-cache nginx openssl ca-certificates RUN mkdir -p /app/data /app/logs /app/cache /app/downloads /app/html /tmp/nginx && \ mkdir -p /tmp/nginx/client_body /tmp/nginx/proxy /tmp/nginx/fastcgi /tmp/nginx/uwsgi /tmp/nginx/scgi && \ mkdir -p /var/lib/nginx/logs && touch /var/lib/nginx/logs/error.log COPY --from=builder /build/target/release/tomato-novel-downloader /app/bot COPY nginx.conf /etc/nginx/nginx.conf COPY fake_error.html /app/html/fake_error.html RUN chown -R 1000:1000 /app /tmp/nginx /var/lib/nginx/logs && chmod -R 755 /app /tmp/nginx /var/lib/nginx/logs EXPOSE 7860 USER 1000 WORKDIR /app ENTRYPOINT ["/bin/sh", "-c", "nginx -c /etc/nginx/nginx.conf -g 'daemon off;' & /app/bot & while true; do sleep 3600; done"]