mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 14:16:19 +00:00
usar solo una imagen docker
This commit is contained in:
parent
f645607adf
commit
a12476129c
4 changed files with 49 additions and 58 deletions
|
@ -4,6 +4,7 @@ data/carrefour/
|
|||
downloader/
|
||||
node_modules/
|
||||
*/node_modules/
|
||||
Containerfile
|
||||
*/Containerfile
|
||||
*.warc.zst
|
||||
.git
|
||||
|
|
48
Containerfile
Normal file
48
Containerfile
Normal file
|
@ -0,0 +1,48 @@
|
|||
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
|
||||
ARG S6_OVERLAY_VERSION=3.1.6.2
|
||||
RUN apk add --no-cache nodejs npm jq
|
||||
|
||||
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
|
||||
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
|
||||
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
|
||||
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
|
||||
|
||||
# Cron scraper
|
||||
RUN printf "#!/bin/sh\nexec bun /bin/scraper auto\n" > /etc/periodic/daily/scraper \
|
||||
&& chmod +x /etc/periodic/daily/scraper
|
||||
|
||||
# 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
|
||||
|
||||
VOLUME /db
|
||||
ENV NODE_ENV=production
|
||||
ENV DB_PATH=/db/db.db
|
||||
EXPOSE 3000
|
||||
|
||||
# Servicios
|
||||
RUN mkdir -p /etc/services.d/sitio /etc/services.d/scraper && \
|
||||
printf "#!/command/execlineb -P\nnode /usr/src/app\n" > /etc/services.d/sitio/run && \
|
||||
chmod +x /etc/services.d/sitio/run && \
|
||||
printf "#!/command/execlineb -P\nbusybox crond -f -l2\n" > /etc/services.d/scraper/run && \
|
||||
chmod +x /etc/services.d/scraper/run
|
||||
|
||||
ENTRYPOINT ["/init"]
|
|
@ -1,27 +0,0 @@
|
|||
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"]
|
|
@ -1,31 +0,0 @@
|
|||
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", "."]
|
Loading…
Reference in a new issue