From 5a95ec45867f3d62b1923ae3894a7fe35aab3f78 Mon Sep 17 00:00:00 2001 From: Emelie Graven Date: Tue, 16 Nov 2021 16:03:41 +0100 Subject: [PATCH] Update docker image, add drone pipeline --- .drone.yml | 13 +++++++++++++ Dockerfile | 35 +++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 00000000..ae237fc7 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,13 @@ + +kind: pipeline +name: default + +steps: +- name: docker + image: plugins/docker + settings: + repo: egraven/zola + auto_tag: true + username: egraven + password: + from_secret: DOCKER_TOKEN diff --git a/Dockerfile b/Dockerfile index 2db2d144..67b10d22 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,28 @@ -FROM rust:slim AS builder +FROM lukemathwalker/cargo-chef:latest-rust-slim AS chef +WORKDIR zola -RUN apt-get update -y && \ - apt-get install -y python-pip make g++ python-setuptools libssl-dev pkg-config rsync && \ - pip install dockerize && \ - rustup target add x86_64-unknown-linux-gnu +FROM chef AS deps +#RUN rustup target add x86_64-unknown-linux-musl +RUN apt-get update && apt-get install -y make g++ pkg-config libssl-dev # musl-tools -WORKDIR /app +FROM deps AS recipe COPY . . +RUN cargo chef prepare --recipe-path recipe.json -RUN cargo build --release --target x86_64-unknown-linux-gnu +FROM deps AS build +COPY --from=recipe /zola/recipe.json recipe.json +#RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json +RUN cargo chef cook --release --recipe-path recipe.json -RUN mv target/x86_64-unknown-linux-gnu/release/zola /usr/bin -RUN mkdir -p /workdir -WORKDIR /workdir -RUN dockerize -n -o /workdir /usr/bin/zola +COPY . . +#RUN cargo build --release --target x86_64-unknown-linux-musl --bin zola +RUN cargo build --release --bin zola +FROM debian:bullseye-slim AS runtime +WORKDIR zola +#COPY --from=build zola/target/x86_64-unknown-linux-musl/release/zola /usr/local/bin/ +COPY --from=build zola/target/release/zola /usr/local/bin/ +ENTRYPOINT ["/usr/local/bin/zola"] + +LABEL org.opencontainers.image.authors="Emelie Graven " -FROM scratch -COPY --from=builder /workdir . -ENTRYPOINT [ "/usr/bin/zola" ]