-
Notifications
You must be signed in to change notification settings - Fork 20
/
Dockerfile.build
60 lines (51 loc) · 2.07 KB
/
Dockerfile.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
FROM --platform=linux/amd64 docker.io/golang:1.22.2-bullseye
ENV COMMIT=dev
ENV VERSION=0.0.0
# Preparations
RUN apt-get update && apt-get install -y wget build-essential
# Download and extract dependency sources
RUN cd /tmp && \
wget http://www.alsa-project.org/files/pub/lib/alsa-lib-1.2.10.tar.bz2 && \
tar -xvf alsa-lib-1.2.10.tar.bz2
RUN cd /tmp && \
wget https://downloads.xiph.org/releases/ogg/libogg-1.3.5.tar.xz && \
tar -xvf libogg-1.3.5.tar.xz
RUN cd /tmp && \
wget https://downloads.xiph.org/releases/vorbis/libvorbis-1.3.7.tar.xz && \
tar -xvf libvorbis-1.3.7.tar.xz
# Depencies arguments
ARG TARGET
ARG CC
# Install toolchain for anything besides arm-rpi-linux-gnueabihf
RUN if [ ${TARGET} != arm-rpi-linux-gnueabihf ]; then \
apt-get install -y gcc-${TARGET} ; \
fi
# Install custom toolchain for arm-rpi-linux-gnueabihf
RUN if [ ${TARGET} = arm-rpi-linux-gnueabihf ]; then \
cd /tmp && \
wget https://github.com/devgianlu/rpi-toolchain/releases/download/v1/arm-rpi-linux-gnueabihf.tar.gz && \
tar -C /usr --strip-components=1 -xzf arm-rpi-linux-gnueabihf.tar.gz ; \
fi
# Compile dependency sources
RUN cd /tmp/alsa-lib-1.2.10 && \
./configure --enable-shared=yes --enable-static=no --with-pic --host=${TARGET} --prefix=/tmp/deps/${TARGET} && \
make && make install
RUN cd /tmp/libogg-1.3.5 && \
./configure --host=${TARGET} --prefix=/tmp/deps/${TARGET} && \
make && make install
RUN cd /tmp/libvorbis-1.3.7 && \
./configure --host=${TARGET} --prefix=/tmp/deps/${TARGET} && \
make && make install
# Golang arguments
ARG GOARCH
ARG GOAMD64
ARG GOARM
# Compile
WORKDIR /src
ENV CGO_ENABLED=1 PKG_CONFIG_PATH=/tmp/deps/${TARGET}/lib/pkgconfig/ CC=${CC} \
GOARCH=${GOARCH} GOAMD64=${GOAMD64} GOARM=${GOARM} GOOUTSUFFIX='' \
GOCACHE=/src/.gocache/go-build GOMODCACHE=/src/.gocache/mod
CMD go build \
-buildvcs=false \
-ldflags="-X github.com/devgianlu/go-librespot.commit=${COMMIT} -X github.com/devgianlu/go-librespot.version=${VERSION}" \
-o ./go-librespot${GOOUTSUFFIX} -a ./cmd/daemon