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.