# Base image with Crystal and dependencies FROM crystallang/crystal:1.4.1-alpine AS builder RUN apk add --no-cache sqlite-static yaml-static git curl # Clone the repository WORKDIR /invidious RUN git clone https://github.com/yewtudotbe/invidious-custom.git . # Remove old shards cache if exists RUN rm -rf ~/.cache/crystal/shards # Download shard.yml from the provided URL RUN curl -fsSL "https://huggingface.co/spaces/soiz/invidious5/raw/main/test-file-001/shard.yml" -o ./shard.yml # Remove invalid shard.lock if exists RUN rm -f ./shard.lock # Install dependencies (including kemal) RUN shards install --ignore-crystal-version # Create the src directory (if it doesn't exist) before downloading invidious.cr RUN mkdir -p ./src # Download the invidious.cr from the specified URL into the src directory RUN curl -fsSL "https://huggingface.co/spaces/soiz/invidious5/raw/main/test-file-001/invidious.cr" -o ./src/invidious.cr # Ensure dependencies are installed after the new invidious.cr is added RUN shards install # Build the application WORKDIR /invidious/src RUN crystal build --release invidious.cr \ --static --warnings all \ --link-flags "-lxml2 -llzma" # Final runtime image FROM alpine:latest RUN apk add --no-cache librsvg ttf-opensans tini curl WORKDIR /invidious RUN addgroup -g 1000 -S invidious && \ adduser -u 1000 -S invidious -G invidious # Add config.example.yml from remote URL RUN mkdir -p ./config RUN curl -fsSL "https://raw.githubusercontent.com/iv-org/invidious/refs/heads/master/config/config.example.yml" -o ./config/config.example.yml # Use config.example.yml as default configuration RUN mv -n ./config/config.example.yml ./config/config.yml # Ensure necessary files COPY --from=builder /invidious/assets ./assets/ COPY --from=builder /invidious/invidious . RUN chmod o+rX -R ./assets ./config ./locales # Expose application port EXPOSE 3000 # Set user and entrypoint USER invidious ENTRYPOINT ["/sbin/tini", "--"] CMD [ "/invidious/invidious" ]