Compare commits

..

7 commits

Author SHA1 Message Date
448341d4e9 pushear nuevo contenedor en gh actions 2024-01-06 23:05:49 -03:00
f68ede609d actualizar lockfile 2024-01-06 23:04:18 -03:00
dbdd19a4c2 usar croner en vez de cron
uso de memoria?
2024-01-06 23:03:16 -03:00
923dd0b910 basar imagen en wolfi 2024-01-06 22:42:24 -03:00
10ea426fb1 ignorar rust target 2024-01-06 22:42:19 -03:00
adb98caa7f probar usar imagen basada en debian 2024-01-06 22:30:55 -03:00
7c967a8d74 no usar tini
parece que railway.app ya usa algun pid 1
2024-01-06 21:19:53 -03:00
6 changed files with 8 additions and 42 deletions

View file

@ -10,4 +10,5 @@ Dockerfile
*/Dockerfile */Dockerfile
*.warc.zst *.warc.zst
.git .git
scraper/debug/ scraper/debug/
*/target/

View file

@ -25,34 +25,6 @@ jobs:
- run: bun check - run: bun check
working-directory: ./scraper working-directory: ./scraper
build-and-push-scraper:
runs-on: ubuntu-latest
needs: check
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/scraper
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: scraper/Containerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-and-push-sitio: build-and-push-sitio:
needs: check needs: check
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -77,7 +49,6 @@ jobs:
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with: with:
context: . context: .
file: sitio/Containerfile
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}

View file

@ -10,8 +10,8 @@ RUN cd sitio && \
bun run build bun run build
RUN bun build scraper/cli.ts --target=bun --outfile=/tmp/cli.build.js RUN bun build scraper/cli.ts --target=bun --outfile=/tmp/cli.build.js
FROM base FROM cgr.dev/chainguard/wolfi-base
RUN apk add --no-cache tini nodejs npm jq RUN apk add --no-cache nodejs npm jq bun
# Sitio # Sitio
COPY --from=build /usr/src/app/sitio/package.json package.real.json COPY --from=build /usr/src/app/sitio/package.json package.real.json
@ -27,5 +27,4 @@ ENV NODE_ENV=production
ENV DB_PATH=/db/db.db ENV DB_PATH=/db/db.db
EXPOSE 3000 EXPOSE 3000
ENTRYPOINT ["tini", "--"]
CMD ["node", "."] CMD ["node", "."]

BIN
bun.lockb

Binary file not shown.

View file

@ -38,7 +38,7 @@
"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", "croner": "^8.0.0",
"dayjs": "^1.11.10", "dayjs": "^1.11.10",
"drizzle-orm": "^0.29.1" "drizzle-orm": "^0.29.1"
} }

View file

@ -1,14 +1,9 @@
import { spawn } from "child_process"; import { spawn } from "child_process";
import { CronJob } from "cron"; import Cron from "croner";
if (process.env.NODE_ENV === "production") { if (process.env.NODE_ENV === "production") {
const job = CronJob.from({ const job = Cron("15 3 * * *", () => {
cronTime: "0 3 * * *", runScraper();
onTick: function () {
runScraper();
},
start: true,
timeZone: "America/Argentina/Buenos_Aires",
}); });
} }