forked from devgianlu/go-librespot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.build
More file actions
43 lines (36 loc) · 1.33 KB
/
Dockerfile.build
File metadata and controls
43 lines (36 loc) · 1.33 KB
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
FROM --platform=linux/amd64 docker.io/golang:1.22.2
# Build tools
RUN apt-get update && apt-get install -y zip autoconf autopoint libtool
# Install toolchain
ARG TARGET
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 ; \
else \
apt-get install -y "gcc-$TARGET" ; \
fi
# Move to build directory
WORKDIR /build
# Setup vcpkg
ADD https://github.com/microsoft/vcpkg.git#2025.09.17 vcpkg
RUN cd vcpkg && ./bootstrap-vcpkg.sh
ENV VCPKG_ROOT=/build/vcpkg
ENV PATH="$VCPKG_ROOT:$PATH"
# Compile dependencies
ARG TRIPLET
COPY vcpkg.json vcpkg-configuration.json ./
COPY vcpkg-triplets ./vcpkg-triplets
RUN --mount=type=cache,target=/build/vcpkg/downloads \
--mount=type=cache,target=/build/vcpkg/buildtrees \
vcpkg install --triplet "$TRIPLET"
# Go compilation setup
ARG GOCC
ARG GOARCH
ARG GOAMD64
ARG GOARM
WORKDIR /src
ENV CGO_ENABLED=1 PKG_CONFIG_PATH="/build/vcpkg_installed/$TRIPLET/lib/pkgconfig" CC="$GOCC" \
GOARCH="$GOARCH" GOAMD64="$GOAMD64" GOARM="$GOARM" \
GOCACHE=/src/.gocache/go-build GOMODCACHE=/src/.gocache/mod
CMD ["go", "build", "-o", "./go-librespot", "-a", "-ldflags", "-s -w", "./cmd/daemon"]