Dockerfile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. FROM crystallang/crystal:1.2.2-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 --from=quay.io/invidious/lsquic-compiled /root/liblsquic.a ./lib/lsquic/src/lsquic/ext/liblsquic.a
  9. COPY ./src/ ./src/
  10. # TODO: .git folder is required for building – this is destructive.
  11. # See definition of CURRENT_BRANCH, CURRENT_COMMIT and CURRENT_VERSION.
  12. COPY ./.git/ ./.git/
  13. # Required for fetching player dependencies
  14. COPY ./scripts/ ./scripts/
  15. COPY ./assets/ ./assets/
  16. COPY ./videojs-dependencies.yml ./videojs-dependencies.yml
  17. RUN crystal spec --warnings all \
  18. --link-flags "-lxml2 -llzma"
  19. RUN if [ "${release}" == 1 ] ; then \
  20. crystal build ./src/invidious.cr \
  21. --release \
  22. --static --warnings all \
  23. --link-flags "-lxml2 -llzma"; \
  24. else \
  25. crystal build ./src/invidious.cr \
  26. --static --warnings all \
  27. --link-flags "-lxml2 -llzma"; \
  28. fi
  29. FROM alpine:latest
  30. RUN apk add --no-cache librsvg ttf-opensans
  31. WORKDIR /invidious
  32. RUN addgroup -g 1000 -S invidious && \
  33. adduser -u 1000 -S invidious -G invidious
  34. COPY --chown=invidious ./config/config.* ./config/
  35. RUN mv -n config/config.example.yml config/config.yml
  36. RUN sed -i 's/host: \(127.0.0.1\|localhost\)/host: postgres/' config/config.yml
  37. COPY ./config/sql/ ./config/sql/
  38. COPY ./locales/ ./locales/
  39. COPY --from=builder /invidious/assets ./assets/
  40. COPY --from=builder /invidious/invidious .
  41. RUN chmod o+rX -R ./assets ./config ./locales
  42. EXPOSE 3000
  43. USER invidious
  44. CMD [ "/invidious/invidious" ]