2

This is 2nd time I am performing the build and all the dependencies required for the build are already installed in the system. All the repos specified in source-repository-package field are also downloaded in the last build.

Still, cabal is trying to fetch all new commits even though the tag is the same.

How do I tell cabal to perform the build absolutely offline without trying to fetch any new packages or fetching git repos, when they are all already available?

Step 15/30 : RUN cabal build api-server
 ---> Running in f68d5aa82ed1
From https://github.com/input-output-hk/cardano-addresses
 * [new branch]        erikd/ghc-9.2 -> origin/erikd/ghc-9.2
   b745e498..57e3e509  gh-pages      -> origin/gh-pages
   2c0923cb..5ceb877c  master        -> origin/master
 * c63a30e1...2b0d7c2f newhoggy/update-index-state -> origin/newhoggy/update-index-state  (forced update)
From https://github.com/input-output-hk/cardano-ledger
 * [new branch]          aniketd/fix-redeemer-codec -> origin/aniketd/fix-redeemer-codec
 * [new branch]          aniketd/move-shelley-era-indep-generators-to-tpraos-testlib -> origin/aniketd/move-shelley-era-indep-generators-to-tpraos-testlib
 * [new branch]          aniketd/testlibs-for-all -> origin/aniketd/testlibs-for-all
 * [new branch]          erikd/srp-testing      -> origin/erikd/srp-testing
 * [new branch]          fix-hls-kinda          -> origin/fix-hls-kinda
   8e3886fc5..7f001b64f  gh-pages               -> origin/gh-pages
 * [new branch]          jc/rainbow-in-the-dark -> origin/jc/rainbow-in-the-dark
 * [new branch]          jj/constraints         -> origin/jj/constraints
 * [new branch]          jj/enactment-impl      -> origin/jj/enactment-impl
 * 125399186...6fdcd40e7 jj/pparams-lens        -> origin/jj/pparams-lens  (forced update)
 * [new branch]          jj/pretty-generic      -> origin/jj/pretty-generic
 * [new branch]          lehins/move-orphans-in -> origin/lehins/move-orphans-in

Above is the log when trying to build my code after 30 days without changing anything in the dependencies.

Edit

Sample Dockerfile

FROM  gitlab:5050/haskell as dependencycache
WORKDIR /app
COPY ./.dummyProject/ ./
COPY ./api/cabal.project ./
RUN cabal update 
RUN cabal run dummyProject

FROM  gitlab:5050/haskell 
WORKDIR /app
COPY --from=dependencycache /root/.cabal/ /root/.cabal/
COPY --from=dependencycache /app/dist-newstyle/src/ /app/dist-newstyle/src/
COPY ./api/ .
RUN  cabal build api-server  # would be awesome if i could say cabal
                             # to not use internet for this stage and below
RUN  cabal install api-server 

Note that the build flags of dummyproject and dependency are exactly the same.

Sudip Bhattarai
  • 1,082
  • 9
  • 23
  • [Related](https://stackoverflow.com/questions/73583888/how-to-actually-use-already-installed-versions-of-a-package-or-find-out-why-it) (perhaps even duplicate?) – leftaroundabout Mar 08 '23 at 13:13
  • 1
    Looks like docker. Are you sure this is cabal's fault? If a previous step is being rerun, then those dependencies are not, in fact, also downloaded -- at least, from the point of view of the docker image. – Daniel Wagner Mar 08 '23 at 15:02
  • @DanielWagner , I guess Timestamps could change when performing file copy. But all the dependencies are already there so no need to fetch anything at that point. – Sudip Bhattarai Mar 08 '23 at 18:13
  • @SudipBhattarai if you are running `cabal build` in a docker container, when you trun down the docker container dependencies are not there any more (unless you have a mounted volume), so you need to fetch them again. Try doing the same with `pip install requierements` of `npm`, you'll get the same results. – lsmor Mar 09 '23 at 07:24
  • @Ismor, The reason I started with dummy project is for that exact reason. The code of the Dummy project doesn't change. so the re-fetching of dependencies occurs only if I change the `cabal.project` file which I haven't done. – Sudip Bhattarai Mar 09 '23 at 09:15
  • If you want manual control of a git repo, one thing you could do would be to list a (relative) path to that repo in the `packages:` field of your `cabal.project` (i.e. rather than listing it as a `source-repository-package`). (BUT it would be good to post a minimal reproducing example. I'm not convinced you're doing your docker bits right yet.) – Daniel Wagner Mar 09 '23 at 18:45

0 Answers0