denodrivers / sqlite3

The fastest and correct SQLite3 module for Deno runtime
https://jsr.io/@db/sqlite
Apache License 2.0
265 stars 22 forks source link

Do not fetch native module every time running docker image #137

Closed M4RC3L05 closed 2 months ago

M4RC3L05 commented 2 months ago

Hi!

Currently, every time i run my docker image, i get the log of the downloading of the native module Downloading https://github.com/denodrivers/sqlite3/releases/download/0.12.0/libsqlite3.so.

I would like to know if there is a way to have this cached as a step on the dockerfile to not have to re-download the native module every time i run my docker image.

My dockerfile:

FROM docker.io/denoland/deno:alpine-1.46.3

RUN mkdir /app
RUN chown -R deno:deno /app

USER deno

WORKDIR /app

COPY --chown=deno:deno . .
RUN mkdir /app/data

RUN deno task deps

VOLUME [ "/app/data" ]

EXPOSE 4321 4322
DjDeveloperr commented 2 months ago

Hi! You should be able to download the native module in your app directory and specify path in DENO_SQLITE_PATH env variable to make it load from a specific location instead of automatic download and caching.

Though I'm not sure if that's what you're trying to do. Because the download should be cached on the first run, it sits where Deno dependencies downloaded from the internet stay as well. Not that familiar with Docker myself. Are all dependencies being redownloaded, or just the native module on each run?

M4RC3L05 commented 2 months ago

Hey, just the native module, when i run deno task deps it calls deno cache to cache deps.

M4RC3L05 commented 2 months ago

Well i guess i found a way, if i add RUN deno eval --unstable-ffi "import '@db/sqlite'" after the RUN deno task deps step in the dockerfile, I get Downloading https://github.com/denodrivers/sqlite3/releases/download/0.12.0/libsqlite3.so while building the docker image but when i run the image, that same logs no longer appears, so it got cached during build.

Closing as it seems to be fixed