Invidious is an alternative front-end to YouTube https://invidious.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.8 KiB

  1. # https://github.com/openssl/openssl/releases/tag/openssl-3.6.3
  2. ARG OPENSSL_VERSION='3.6.3'
  3. ARG OPENSSL_SHA256='243a86649cf6f23eeb6a2ff2456e09e5d77dd9018a54d3d96b0c6bdd6ba6c7f1'
  4. FROM 84codes/crystal:1.20.3-alpine AS dependabot-crystal
  5. # We compile openssl ourselves due to a memory leak in how crystal interacts
  6. # with openssl
  7. # Reference: https://github.com/iv-org/invidious/issues/1438#issuecomment-3087636228
  8. FROM dependabot-crystal AS openssl-builder
  9. RUN apk add --no-cache curl perl linux-headers
  10. WORKDIR /
  11. ARG OPENSSL_VERSION
  12. ARG OPENSSL_SHA256
  13. RUN curl -Ls "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz" --output openssl-${OPENSSL_VERSION}.tar.gz
  14. RUN echo "${OPENSSL_SHA256} openssl-${OPENSSL_VERSION}.tar.gz" | sha256sum -c
  15. RUN tar -xzvf openssl-${OPENSSL_VERSION}.tar.gz
  16. RUN cd openssl-${OPENSSL_VERSION} && ./Configure --openssldir=/etc/ssl && make -j$(nproc)
  17. FROM dependabot-crystal AS builder
  18. RUN apk add --no-cache sqlite-static yaml-static
  19. RUN apk del openssl-dev openssl-libs-static
  20. ARG release
  21. WORKDIR /invidious
  22. COPY ./shard.yml ./shard.yml
  23. COPY ./shard.lock ./shard.lock
  24. RUN shards install --production
  25. COPY ./src/ ./src/
  26. # TODO: .git folder is required for building – this is destructive.
  27. # See definition of CURRENT_BRANCH, CURRENT_COMMIT and CURRENT_VERSION.
  28. COPY ./.git/ ./.git/
  29. # Required for fetching player dependencies
  30. COPY ./scripts/ ./scripts/
  31. COPY ./assets/ ./assets/
  32. COPY ./videojs-dependencies.yml ./videojs-dependencies.yml
  33. RUN crystal spec --warnings all \
  34. --link-flags "-lxml2 -llzma"
  35. ARG OPENSSL_VERSION
  36. COPY --from=openssl-builder /openssl-${OPENSSL_VERSION} /openssl-${OPENSSL_VERSION}
  37. RUN --mount=type=cache,target=/root/.cache/crystal if [[ "${release}" == 1 ]] ; then \
  38. PKG_CONFIG_PATH=/openssl-${OPENSSL_VERSION} \
  39. crystal build ./src/invidious.cr \
  40. --release \
  41. --static --warnings all \
  42. --link-flags "-lxml2 -llzma"; \
  43. else \
  44. PKG_CONFIG_PATH=/openssl-${OPENSSL_VERSION} \
  45. crystal build ./src/invidious.cr \
  46. --static --warnings all \
  47. --link-flags "-lxml2 -llzma"; \
  48. fi
  49. FROM alpine:3.24
  50. RUN apk add --no-cache rsvg-convert ttf-opensans tini tzdata
  51. WORKDIR /invidious
  52. RUN addgroup -g 1000 -S invidious && \
  53. adduser -u 1000 -S invidious -G invidious
  54. COPY --chown=invidious ./config/config.* ./config/
  55. RUN mv -n config/config.example.yml config/config.yml
  56. RUN sed -i 's/host: \(127.0.0.1\|localhost\)/host: invidious-db/' config/config.yml
  57. COPY ./config/sql/ ./config/sql/
  58. COPY ./locales/ ./locales/
  59. COPY --from=builder /invidious/assets ./assets/
  60. COPY --from=builder /invidious/invidious .
  61. RUN chmod o+rX -R ./assets ./config ./locales
  62. EXPOSE 3000
  63. USER invidious
  64. ENTRYPOINT ["/sbin/tini", "--"]
  65. CMD [ "/invidious/invidious" ]