From fa9a01026366d3fbdc6f7b1789493fa81e7308f0 Mon Sep 17 00:00:00 2001 From: Nulo Date: Thu, 11 Jan 2024 17:40:09 -0300 Subject: [PATCH] wip: docker -rs --- Dockerfile.scraper | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Dockerfile.scraper b/Dockerfile.scraper index c44dc49..79f0b0e 100644 --- a/Dockerfile.scraper +++ b/Dockerfile.scraper @@ -7,17 +7,25 @@ COPY . . RUN bun install --frozen-lockfile RUN bun build scraper/cli.ts --target=bun --outfile=/tmp/cli.build.js -FROM base +FROM docker.io/rust:1.67 as rs-build +WORKDIR /usr/src/app +COPY scraper-rs/ . +RUN cargo install --path . + +FROM docker.io/oven/bun:1-slim +RUN apt-get update && apt-get install -y extra-runtime-dependencies cron && rm -rf /var/lib/apt/lists/* # Scraper COPY --from=build /tmp/cli.build.js /bin/scraper COPY --from=build /usr/src/app/db-datos/drizzle /bin/drizzle +COPY --from=rs-build /usr/local/cargo/bin/scraper-rs /usr/local/bin/scraper-rs ENV NODE_ENV=production ENV DB_PATH=/db/db.db # Cron scraper -RUN printf "#!/bin/sh\nexec bun /bin/scraper auto\n" > /etc/periodic/daily/scraper \ - && chmod +x /etc/periodic/daily/scraper +RUN printf "0 2 * * * bun /bin/scraper auto\n" > /etc/cron.d/scraper \ + && chmod 0644 /etc/cron.d/scraper \ + && crontab /etc/cron.d/scraper -CMD ["busybox", "crond", "-f", "-l2"] \ No newline at end of file +CMD ["cron", "-f"] \ No newline at end of file