Docker
parent
d0acf77f88
commit
e4afe7371d
24
Dockerfile
24
Dockerfile
|
@ -1,12 +1,29 @@
|
||||||
|
# This Dockerfile has been specifically crafted to be run on an AMD64 build host, where
|
||||||
|
# the build should compile for both amd64 and arm64 targets
|
||||||
|
#
|
||||||
|
# Building on any other platform, or building for only a single target will be significantly
|
||||||
|
# slower compared to a platform agnostic Dockerfile, or might not work at all
|
||||||
|
#
|
||||||
|
# This has been done to make this file be optimized for use within GitHub Actions,
|
||||||
|
# as using QEMU to compile takes way too long (multiple hours)
|
||||||
|
|
||||||
# Builder
|
# Builder
|
||||||
FROM --platform=linux/amd64 rust:1.80.1-slim AS builder
|
FROM --platform=linux/amd64 rust:1.80.1-bullseye AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Add extra build dependencies here
|
# Add extra build dependencies here
|
||||||
RUN apt-get update && apt-get install -yqq \
|
RUN apt-get update && apt install -yqq \
|
||||||
cmake gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu libpq-dev
|
cmake gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu libpq-dev
|
||||||
|
|
||||||
|
# Manually compile an arm64 build of libpq
|
||||||
|
RUN wget https://ftp.postgresql.org/pub/source/v16.4/postgresql-16.4.tar.bz2 && \
|
||||||
|
tar xjf postgresql-16.4.tar.bz2 && \
|
||||||
|
cd postgresql-16.4 && \
|
||||||
|
./configure --host=aarch64-linux-gnu --enable-shared --disable-static --without-readline --without-zlib --without-icu && \
|
||||||
|
cd src/interfaces/libpq && \
|
||||||
|
make
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu
|
RUN rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu
|
||||||
|
@ -14,7 +31,8 @@ RUN rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu
|
||||||
# Add `--no-default-features` if you don't want stats collection
|
# Add `--no-default-features` if you don't want stats collection
|
||||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
--mount=type=cache,target=/app/target \
|
--mount=type=cache,target=/app/target \
|
||||||
cargo build --release --target=x86_64-unknown-linux-gnu --target=aarch64-unknown-linux-gnu && \
|
cargo build --release --target=x86_64-unknown-linux-gnu && \
|
||||||
|
RUSTFLAGS='-L /app/postgresql-16.4/src/interfaces/libpq -C linker=aarch64-linux-gnu-gcc' cargo build --release --target=aarch64-unknown-linux-gnu && \
|
||||||
# Copy the executables outside of /target as it'll get unmounted after this RUN command
|
# Copy the executables outside of /target as it'll get unmounted after this RUN command
|
||||||
cp /app/target/x86_64-unknown-linux-gnu/release/spoticord /app/x86_64 && \
|
cp /app/target/x86_64-unknown-linux-gnu/release/spoticord /app/x86_64 && \
|
||||||
cp /app/target/aarch64-unknown-linux-gnu/release/spoticord /app/aarch64
|
cp /app/target/aarch64-unknown-linux-gnu/release/spoticord /app/aarch64
|
||||||
|
|
Loading…
Reference in New Issue