Invidious: Request: Docker image based on Alpine (for ARM)

Created on 12 Feb 2019  路  8Comments  路  Source: iv-org/invidious

For those of us who would like to run Invidious in our SBC (such Raspberry Pi) ARM computers it would be nice if a Dockerfile based on Alpine image could be provided.

I've tried to create one myself but I get an error while trying to build. I don't know if by installing more dependencies it would be possible to build Invidious for Musl or if glibc is required.

docker run -it --rm alpine /bin/ash

apk --no-cache add crystal shards

git clone https://github.com/omarroth/invidious --depth=1 && cd invidious

shards

crystal build src/invidious.cr --release
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lpthread (this usually means you need to install the development package for libpthread)
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lrt (this usually means you need to install the development package for librt)
/usr/lib/gcc/x86_64-alpine-linux-musl/8.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared (this usually means you need to install the development package for libssp_nonshared)
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/root/.cache/crystal/usr-lib-crystal-core-ecr-process.cr/macro_run'  -rdynamic  -lpcre -lgc -lpthread /usr/lib/crystal/core/ext/libcrystal.a -levent -lrt -L/usr/lib -L/usr/local/lib`

Adding extra libraries didn't help

apk --no-cache add openssl libressl-dev libpthread-stubs
enhancement

Most helpful comment

Looks like Crystal is only available for x64 on Alpine: https://pkgs.alpinelinux.org/packages?name=crystal&branch=edge
I've contacted the package maintainer, asking if adding support for other architectures is possible.

Any news on that? I would love to run Invidious on my Raspberry Pi at home.

I found some ways to cross-compile Crystal for ARM but they do not seem exactly trivial.

All 8 comments

The problem appears to be that it's trying to pull dependencies for x86_64, which likely won't work on ARM.

Unfortunately to my knowledge there isn't an official package of Crystal for arm devices. I've compiled my own version that I'll try to set up as a proper repository when I have time. I'll keep this open but it may be a while before it's supported.

Sorry, I pasted the output from my x86_64 machine thinking I was on my ARM machine :/

I can now successfully compile it using Alpine on x86_64 (credits). Here is the Dockerfile in case someone is interested

FROM alpine

RUN apk add --no-cache --virtual .build-dependencies crystal g++ gc-dev git libc-dev libevent-dev libxml2-dev llvm llvm-dev llvm-libs llvm-static make openssl openssl-dev pcre-dev readline-dev shards sqlite-dev yaml-dev zlib zlib-dev

ADD . /invidious

WORKDIR /invidious

RUN shards && crystal build src/invidious.cr --release
# TODO build with --static
# TODO Housekeeping: apk del .build-dependencies

CMD ["/invidious/invidious"]

The Alpine image is 50% lighter than the Arch one and it could probably be reduced even more once build time dependencies are removed. It is also significantly faster to build than the Arch one, although to be honest I didn't even tested if the Alpine one works well because I'm only interested on the ARM version.

Using crystal build src/invidious.cr --release --static does not work in spite of being officially supported.

However, for the ARM version of Alpine, as you mentioned, Crystal is not available. Here is a recent discussion about the topic, including a link with instructions for cross-compiling it. I'll try them when I have more time.

This has been implemented with https://github.com/omarroth/invidious/pull/665.

Great news. To be consistent, it will be also great if the official docker-compose.yml used the Alpine based image of Postgres

This has been implemented with #665.

Is the Alpine version supposed to work for ARM? I get errors when building

$ uname -a
Linux orangepi 4.19.57-sunxi #5.90 SMP Fri Jul 5 17:58:43 CEST 2019 armv7l GNU/Linux

$ git log -1
commit b63f469110b6d561e06ba7a39a459b71166ef523
Author: Omar Roth <redacted>
Date:   Fri Aug 9 14:09:24 2019 -0500

Fix typo in ConfigPreferences

$ docker-compose build invidious
Building invidious
Step 1/20 : FROM alpine:latest AS builder
---> 962e8b19ad7b
Step 2/20 : RUN apk add -u crystal shards libc-dev     yaml-dev libxml2-dev sqlite-dev sqlite-static zlib-dev openssl-dev
---> Running in 0c9fbabeae7f
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/armv7/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/armv7/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
crystal (missing):
required by: world[crystal]
shards (missing):
required by: world[shards]
ERROR: Service 'invidious' failed to build: The command '/bin/sh -c apk add -u crystal shards libc-dev     yaml-dev libxml2-dev sqlite-dev sqlite-static zlib-dev openssl-dev' returned a non-zero code: 2

Looks like Crystal is only available for x64 on Alpine: https://pkgs.alpinelinux.org/packages?name=crystal&branch=edge
I've contacted the package maintainer, asking if adding support for other architectures is possible.

it will be also great if the official docker-compose.yml used the Alpine based image of Postgres

https://github.com/omarroth/invidious/pull/687

Looks like Crystal is only available for x64 on Alpine: https://pkgs.alpinelinux.org/packages?name=crystal&branch=edge
I've contacted the package maintainer, asking if adding support for other architectures is possible.

Any news on that? I would love to run Invidious on my Raspberry Pi at home.

I found some ways to cross-compile Crystal for ARM but they do not seem exactly trivial.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Atrate picture Atrate  路  4Comments

dimqua picture dimqua  路  4Comments

Jtasiu picture Jtasiu  路  3Comments

SebKranz picture SebKranz  路  3Comments

tmiland picture tmiland  路  4Comments