Dockerfile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. FROM alpine:edge AS builder
  2. RUN apk add --no-cache curl crystal shards libc-dev \
  3. yaml-dev libxml2-dev sqlite-dev zlib-dev openssl-dev \
  4. yaml-static sqlite-static zlib-static openssl-libs-static
  5. WORKDIR /invidious
  6. RUN curl -Lo /etc/apk/keys/omarroth.rsa.pub https://github.com/omarroth/boringssl-alpine/releases/download/1.1.0-r0/omarroth.rsa.pub && \
  7. curl -Lo boringssl-dev.apk https://github.com/omarroth/boringssl-alpine/releases/download/1.1.0-r0/boringssl-dev-1.1.0-r0.apk && \
  8. curl -Lo lsquic.apk https://github.com/omarroth/lsquic-alpine/releases/download/2.6.3-r0/lsquic-2.6.3-r0.apk && \
  9. apk verify --no-cache boringssl-dev.apk lsquic.apk && \
  10. tar -xf boringssl-dev.apk usr/lib/libcrypto.a usr/lib/libssl.a && \
  11. tar -xf lsquic.apk usr/lib/liblsquic.a && \
  12. rm /etc/apk/keys/omarroth.rsa.pub boringssl-dev.apk lsquic.apk
  13. COPY ./shard.yml ./shard.yml
  14. RUN shards update && shards install && \
  15. mv ./usr/lib/* ./lib/lsquic/src/lsquic/ext && \
  16. rm -r ./usr /root/.cache
  17. COPY ./src/ ./src/
  18. # TODO: .git folder is required for building – this is destructive.
  19. # See definition of CURRENT_BRANCH, CURRENT_COMMIT and CURRENT_VERSION.
  20. COPY ./.git/ ./.git/
  21. RUN crystal build ./src/invidious.cr \
  22. --static --warnings all --error-on-warnings \
  23. --link-flags "-lxml2 -llzma"
  24. FROM alpine:latest
  25. RUN apk add --no-cache librsvg ttf-opensans
  26. WORKDIR /invidious
  27. RUN addgroup -g 1000 -S invidious && \
  28. adduser -u 1000 -S invidious -G invidious
  29. COPY ./assets/ ./assets/
  30. COPY --chown=invidious ./config/config.yml ./config/config.yml
  31. RUN sed -i 's/host: \(127.0.0.1\|localhost\)/host: postgres/' config/config.yml
  32. COPY ./config/sql/ ./config/sql/
  33. COPY ./locales/ ./locales/
  34. COPY --from=builder /invidious/invidious .
  35. USER invidious
  36. CMD [ "/invidious/invidious" ]