This repository has been archived on 2023-11-08. You can view files and clone it, but cannot push or open issues or pull requests.
fiddle/Dockerfile

45 lines
1.4 KiB
Text
Raw Permalink Normal View History

2023-06-02 14:27:39 +00:00
FROM docker.io/lukemathwalker/cargo-chef:latest-rust-1.69.0 as chef
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# hadolint ignore=DL3008,DL3009
RUN apt-get update && \
apt-get install -y --no-install-recommends \
wget \
software-properties-common \
clang
WORKDIR /tmp
ARG MOLD_VERSION="1.11.0"
RUN wget -qO- https://github.com/rui314/mold/releases/download/v${MOLD_VERSION}/mold-${MOLD_VERSION}-x86_64-linux.tar.gz | tar xzf - \
&& cp -RT ./mold-${MOLD_VERSION}-x86_64-linux /usr \
&& rm -rf ./mold-${MOLD_VERSION}-x86_64-linux
WORKDIR /
FROM chef as diesel
RUN cargo install diesel_cli --no-default-features --features postgres
FROM chef as planner
WORKDIR /usr/src/fiddle
RUN mkdir src && touch src/main.rs
COPY ./Cargo.toml ./Cargo.lock ./
RUN cargo chef prepare --recipe-path recipe.json
FROM chef as builder
WORKDIR /usr/src/fiddle
COPY ./.cargo ./.cargo
COPY --from=planner /usr/src/fiddle/recipe.json .
RUN cargo chef cook --release --recipe-path recipe.json
COPY ./assets ./assets
COPY ./src ./src
RUN cargo build --release
FROM docker.io/bitnami/minideb:bullseye as runner
RUN install_packages libpq5
WORKDIR /usr/local/bin
COPY --from=diesel /usr/local/cargo/bin/diesel .
WORKDIR /usr/src/fiddle
COPY ./run.sh .
RUN chmod +x ./run.sh
COPY ./migrations ./migrations
COPY --from=builder /usr/src/fiddle/target/release/fiddle ./bin/fiddle
EXPOSE 80
CMD [ "./run.sh" ]