Add rust implementation

This commit is contained in:
2022-12-14 22:33:38 +01:00
parent e36487b5ad
commit a5827721cd
39 changed files with 2473 additions and 1410 deletions

View File

@@ -0,0 +1,21 @@
FROM rust:bullseye AS builder
WORKDIR /app
COPY . .
RUN cargo build --bin books_downloader
FROM debian:bullseye-slim
RUN apt-get update \
&& apt-get install -y openssl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN update-ca-certificates
WORKDIR /app
COPY --from=builder /app/target/debug/books_downloader /usr/local/bin
ENTRYPOINT ["/usr/local/bin/books_downloader"]

View File

@@ -1,26 +1,21 @@
FROM ghcr.io/flibusta-apps/base_docker_images:3.11-poetry-buildtime as build-image
FROM rust:bullseye AS builder
WORKDIR /root/poetry
COPY pyproject.toml poetry.lock /root/poetry/
WORKDIR /app
ENV VENV_PATH=/opt/venv
COPY . .
RUN poetry export --without-hashes > requirements.txt \
&& . /opt/venv/bin/activate \
&& pip install -r requirements.txt --no-cache-dir
RUN cargo build --release --bin books_downloader
FROM python:3.11-slim as runtime-image
FROM debian:bullseye-slim
ENV VENV_PATH=/opt/venv
ENV PATH="$VENV_PATH/bin:$PATH"
RUN apt-get update \
&& apt-get install -y openssl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY ./src/ /app/
COPY ./scripts/* /root/
COPY --from=build-image $VENV_PATH $VENV_PATH
RUN update-ca-certificates
EXPOSE 8080
WORKDIR /app
WORKDIR /app/
CMD bash /root/start.sh
COPY --from=builder /app/target/release/books_downloader /usr/local/bin
ENTRYPOINT ["/usr/local/bin/books_downloader"]