Create Dockerfile
This commit is contained in:
parent
8d45f987d5
commit
6363585b43
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Ignore everything
|
||||||
|
*
|
||||||
|
|
||||||
|
# Except:
|
||||||
|
!/src
|
||||||
|
!/Cargo.lock
|
||||||
|
!/Cargo.toml
|
69
Dockerfile
Normal file
69
Dockerfile
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
FROM rust:slim as builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN rustup default nightly
|
||||||
|
|
||||||
|
# Install a few dependencies
|
||||||
|
RUN set -eux; \
|
||||||
|
apt-get update; \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
pkg-config \
|
||||||
|
clang \
|
||||||
|
build-essential \
|
||||||
|
libssl-dev \
|
||||||
|
libpq-dev \
|
||||||
|
wget; \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install ImageMagick
|
||||||
|
RUN cd / && \
|
||||||
|
wget https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.1-38.tar.gz && \
|
||||||
|
tar xf 7.1.1-38.tar.gz && \
|
||||||
|
rm 7.1.1-38.tar.gz && \
|
||||||
|
cd ImageMagick-7.1.1-38 && \
|
||||||
|
./configure && \
|
||||||
|
make install -j $(nproc) && \
|
||||||
|
cd .. && \
|
||||||
|
rm -rf ImageMagick-7.1.1-38
|
||||||
|
|
||||||
|
# Copy project dependency manifests
|
||||||
|
COPY Cargo.toml Cargo.lock /app/
|
||||||
|
|
||||||
|
# Create dummy file to force cargo to build the dependencies
|
||||||
|
RUN mkdir /app/src && echo "fn main() {}" > /app/src/main.rs
|
||||||
|
|
||||||
|
# Prebuild dependencies
|
||||||
|
RUN cargo build --release
|
||||||
|
|
||||||
|
RUN rm -rf /app/src
|
||||||
|
COPY src /app/src
|
||||||
|
|
||||||
|
# Touch main to force rebuild
|
||||||
|
RUN touch /app/src/main.rs
|
||||||
|
|
||||||
|
# Actually build the binary
|
||||||
|
RUN cargo build --release
|
||||||
|
|
||||||
|
# Use ldd to list all dependencies of /app/target/release/ingest, then copy them to /app/libs
|
||||||
|
# Setting LD_LIBRARY_PATH is necessary to find the ImageMagick libraries
|
||||||
|
RUN mkdir /app/libs && LD_LIBRARY_PATH=/usr/local/lib ldd /app/target/release/ingest | grep "=> /" | \
|
||||||
|
awk '{print $3}' | xargs -I '{}' cp '{}' /app/libs
|
||||||
|
|
||||||
|
# Build the final image
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
LABEL license="MIT"
|
||||||
|
LABEL description="LibreTunes, an open-source browser audio player and \
|
||||||
|
library manager built for collaborative listening."
|
||||||
|
|
||||||
|
# Copy the binary and the compressed assets to the "site root"
|
||||||
|
COPY --from=builder /app/target/release/ingest /ingest
|
||||||
|
|
||||||
|
# Copy libraries to /lib64
|
||||||
|
COPY --from=builder /app/libs /lib64
|
||||||
|
COPY --from=builder /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2
|
||||||
|
|
||||||
|
ENV LD_LIBRARY_PATH=/lib64
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/ingest" ]
|
Loading…
x
Reference in New Issue
Block a user