mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-26 11:36:20 +00:00
Compare commits
No commits in common. "43954d7af8d90755f393f426e75a507f4135c1d0" and "f645607adfe3327f2102bdef54f83ce95507211a" have entirely different histories.
43954d7af8
...
f645607adf
7 changed files with 58 additions and 52 deletions
|
@ -4,10 +4,7 @@ data/carrefour/
|
||||||
downloader/
|
downloader/
|
||||||
node_modules/
|
node_modules/
|
||||||
*/node_modules/
|
*/node_modules/
|
||||||
Containerfile
|
|
||||||
*/Containerfile
|
*/Containerfile
|
||||||
Dockerfile
|
|
||||||
*/Dockerfile
|
|
||||||
*.warc.zst
|
*.warc.zst
|
||||||
.git
|
.git
|
||||||
scraper/debug/
|
scraper/debug/
|
31
Dockerfile
31
Dockerfile
|
@ -1,31 +0,0 @@
|
||||||
FROM docker.io/oven/bun:1-alpine AS base
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
FROM base as build
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
RUN apk add --no-cache nodejs
|
|
||||||
COPY . .
|
|
||||||
RUN bun install --frozen-lockfile
|
|
||||||
RUN cd sitio && \
|
|
||||||
bun run build
|
|
||||||
RUN bun build scraper/cli.ts --target=bun --outfile=/tmp/cli.build.js
|
|
||||||
|
|
||||||
FROM base
|
|
||||||
RUN apk add --no-cache tini nodejs npm jq
|
|
||||||
|
|
||||||
# Sitio
|
|
||||||
COPY --from=build /usr/src/app/sitio/package.json package.real.json
|
|
||||||
RUN sh -c 'echo {\"name\":\"sitio\",\"type\":\"module\",\"dependencies\":$(jq .dependencies < package.real.json)} > package.json' && npm install
|
|
||||||
COPY --from=build /usr/src/app/db-datos node_modules/db-datos
|
|
||||||
COPY --from=build /usr/src/app/sitio/build .
|
|
||||||
|
|
||||||
# Scraper
|
|
||||||
COPY --from=build /tmp/cli.build.js /bin/scraper
|
|
||||||
COPY --from=build /usr/src/app/db-datos/drizzle /bin/drizzle
|
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
ENV DB_PATH=/db/db.db
|
|
||||||
EXPOSE 3000
|
|
||||||
|
|
||||||
ENTRYPOINT ["tini", "--"]
|
|
||||||
CMD ["node", "."]
|
|
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
27
scraper/Containerfile
Normal file
27
scraper/Containerfile
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
FROM docker.io/oven/bun:1-alpine AS base
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
FROM base AS builder
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
COPY . .
|
||||||
|
RUN bun install --frozen-lockfile \
|
||||||
|
&& bun build scraper/cli.ts --target=bun --outfile=/tmp/cli.build.js \
|
||||||
|
&& rm -rf node_modules/
|
||||||
|
|
||||||
|
FROM base
|
||||||
|
RUN apk add --no-cache wget zstd tini
|
||||||
|
RUN printf "#!/bin/sh\nexec bun /bin/scraper auto\n" > /etc/periodic/daily/scraper \
|
||||||
|
&& chmod +x /etc/periodic/daily/scraper
|
||||||
|
|
||||||
|
COPY --from=builder /tmp/cli.build.js /bin/scraper
|
||||||
|
COPY --from=builder /usr/src/app/db-datos/drizzle /bin/drizzle
|
||||||
|
COPY --from=builder /usr/src/app/data /listas
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
VOLUME /db
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV DB_PATH=/db/db.db
|
||||||
|
ENV LISTS_DIR=/listas/
|
||||||
|
|
||||||
|
CMD ["tini", "/bin/busybox", "crond", "-f", "-l2"]
|
||||||
|
# CMD ["bun", "/bin/scraper"]
|
31
sitio/Containerfile
Normal file
31
sitio/Containerfile
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
FROM docker.io/oven/bun:1-alpine as build
|
||||||
|
RUN apk add --no-cache nodejs
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
COPY . .
|
||||||
|
WORKDIR /usr/src/app/sitio
|
||||||
|
RUN bun install && \
|
||||||
|
bun run build
|
||||||
|
|
||||||
|
# FROM docker.io/oven/bun:1-alpine as deps
|
||||||
|
# WORKDIR /usr/src/app/sitio
|
||||||
|
# RUN bun init && bun install "better-sqlite3"@"^9.2.2" "chart.js"@"^4.4.1" "chartjs-adapter-dayjs-4"@"^1.0.4" "dayjs"@"^1.11.10" "drizzle-orm"@"^0.29.1"
|
||||||
|
# COPY --from=build /usr/src/app/db-datos node_modules/db-datos
|
||||||
|
|
||||||
|
FROM docker.io/alpine:3.19
|
||||||
|
RUN apk add --no-cache tini nodejs npm jq
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /usr/src/app/sitio/package.json package.real.json
|
||||||
|
RUN sh -c 'echo {\"name\":\"sitio\",\"type\":\"module\",\"dependencies\":$(jq .dependencies < package.real.json)} > package.json' && npm install
|
||||||
|
COPY --from=build /usr/src/app/db-datos node_modules/db-datos
|
||||||
|
COPY --from=build /usr/src/app/sitio/build .
|
||||||
|
|
||||||
|
# https://github.com/gornostay25/svelte-adapter-bun/issues/39
|
||||||
|
ENV PROTOCOL_HEADER=x-forwarded-proto
|
||||||
|
ENV HOST_HEADER=x-forwarded-host
|
||||||
|
|
||||||
|
VOLUME /db
|
||||||
|
ENV DB_PATH=/db/db.db
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["tini", "node", "."]
|
|
@ -38,7 +38,6 @@
|
||||||
"better-sqlite3": "^9.2.2",
|
"better-sqlite3": "^9.2.2",
|
||||||
"chart.js": "^4.4.1",
|
"chart.js": "^4.4.1",
|
||||||
"chartjs-adapter-dayjs-4": "^1.0.4",
|
"chartjs-adapter-dayjs-4": "^1.0.4",
|
||||||
"cron": "^3.1.6",
|
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
"drizzle-orm": "^0.29.1"
|
"drizzle-orm": "^0.29.1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
import { spawn } from "child_process";
|
|
||||||
import { CronJob } from "cron";
|
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "production") {
|
|
||||||
const job = CronJob.from({
|
|
||||||
cronTime: "0 3 * * *",
|
|
||||||
onTick: function () {
|
|
||||||
runScraper();
|
|
||||||
},
|
|
||||||
start: true,
|
|
||||||
timeZone: "America/Argentina/Buenos_Aires",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function runScraper() {
|
|
||||||
spawn("bun", ["/bin/scraper", "auto"], { stdio: "inherit" });
|
|
||||||
}
|
|
Loading…
Reference in a new issue