Dockerfile 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. FROM crystallang/crystal:1.12.1-alpine AS builder
  2. RUN apk add --no-cache sqlite-static yaml-static
  3. ARG release
  4. WORKDIR /invidious
  5. COPY ./shard.yml ./shard.yml
  6. COPY ./shard.lock ./shard.lock
  7. RUN shards install --production
  8. COPY ./src/ ./src/
  9. # TODO: .git folder is required for building – this is destructive.
  10. # See definition of CURRENT_BRANCH, CURRENT_COMMIT and CURRENT_VERSION.
  11. COPY ./.git/ ./.git/
  12. # Required for fetching player dependencies
  13. COPY ./scripts/ ./scripts/
  14. COPY ./assets/ ./assets/
  15. COPY ./videojs-dependencies.yml ./videojs-dependencies.yml
  16. RUN crystal spec --warnings all \
  17. --link-flags "-lxml2 -llzma"
  18. RUN if [[ "${release}" == 1 ]] ; then \
  19. crystal build ./src/invidious.cr \
  20. --release \
  21. --static --warnings all \
  22. --link-flags "-lxml2 -llzma"; \
  23. else \
  24. crystal build ./src/invidious.cr \
  25. --static --warnings all \
  26. --link-flags "-lxml2 -llzma"; \
  27. fi
  28. FROM alpine:3.18
  29. RUN apk add --no-cache rsvg-convert ttf-opensans tini
  30. WORKDIR /invidious
  31. RUN addgroup -g 1000 -S invidious && \
  32. adduser -u 1000 -S invidious -G invidious
  33. COPY --chown=invidious ./config/config.* ./config/
  34. RUN mv -n config/config.example.yml config/config.yml
  35. RUN sed -i 's/host: \(127.0.0.1\|localhost\)/host: invidious-db/' config/config.yml
  36. COPY ./config/sql/ ./config/sql/
  37. COPY ./locales/ ./locales/
  38. COPY --from=builder /invidious/assets ./assets/
  39. COPY --from=builder /invidious/invidious .
  40. RUN chmod o+rX -R ./assets ./config ./locales
  41. EXPOSE 3000
  42. USER invidious
  43. ENTRYPOINT ["/sbin/tini", "--"]
  44. CMD [ "/invidious/invidious" ]