<div dir="ltr">Hi Cafe,<div><br></div><div>I am trying to set up a useful development container for an open source project I am working on. I have created an image on top of the official Haskell image, expecting a proper installation of ghcup, cabal, stack and hls. The Dockerfile looks like this:</div><div><br></div><div><div style="color:rgb(204,204,204);background-color:rgb(31,31,31);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(197,134,192)">FROM</span> <span style="color:rgb(78,201,176)">haskell</span>:<span style="color:rgb(156,220,254)">8.10</span></div><br><div><span style="color:rgb(197,134,192)">ARG</span> <span style="color:rgb(156,220,254)">USERNAME</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">vscode</span></div><br><br><div><span style="color:rgb(197,134,192)">ENV</span> <span style="color:rgb(156,220,254)">USERNAME</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">${USERNAME}</span> <span style="color:rgb(86,156,214)">\</span></div><div>    <span style="color:rgb(156,220,254)">USER_UID</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">1000</span> <span style="color:rgb(86,156,214)">\</span></div><div>    <span style="color:rgb(156,220,254)">USER_GID</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">1000</span> <span style="color:rgb(86,156,214)">\</span></div><div>    <span style="color:rgb(156,220,254)">DEBIAN_FRONTEND</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">noninteractive</span> <span style="color:rgb(86,156,214)">\</span></div><div>    <span style="color:rgb(156,220,254)">LANG</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">C.UTF8</span> <span style="color:rgb(86,156,214)">\</span></div><div>    <span style="color:rgb(156,220,254)">WDIR</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">/home/</span><span style="color:rgb(156,220,254)">${USERNAME}</span></div><br><div><span style="color:rgb(197,134,192)">RUN</span> <span style="color:rgb(156,220,254)">apt-get</span> <span style="color:rgb(156,220,254)">update</span> <span style="color:rgb(156,220,254)">&&</span> <span style="color:rgb(86,156,214)">\</span></div><div>    <span style="color:rgb(156,220,254)">apt-get</span> <span style="color:rgb(156,220,254)">upgrade</span> <span style="color:rgb(156,220,254)">-y</span> <span style="color:rgb(156,220,254)">&&</span> <span style="color:rgb(86,156,214)">\</span></div><div>    <span style="color:rgb(156,220,254)">apt-get</span> <span style="color:rgb(156,220,254)">install</span> <span style="color:rgb(156,220,254)">-y</span> <span style="color:rgb(156,220,254)">git</span></div><br><div><span style="color:rgb(197,134,192)">RUN</span> <span style="color:rgb(156,220,254)">groupadd</span> <span style="color:rgb(156,220,254)">--gid</span> <span style="color:rgb(156,220,254)">$USER_GID</span> <span style="color:rgb(156,220,254)">$USERNAME</span> <span style="color:rgb(156,220,254)">&&</span> <span style="color:rgb(86,156,214)">\</span></div><div>    <span style="color:rgb(156,220,254)">useradd</span> <span style="color:rgb(156,220,254)">-ms</span> <span style="color:rgb(156,220,254)">/bin/bash</span> <span style="color:rgb(156,220,254)">-K</span> <span style="color:rgb(156,220,254)">MAIL_DIR=/dev/null</span> <span style="color:rgb(156,220,254)">--uid</span> <span style="color:rgb(156,220,254)">$USER_UID</span> <span style="color:rgb(156,220,254)">--gid</span> <span style="color:rgb(156,220,254)">$USER_GID</span> <span style="color:rgb(156,220,254)">-m</span> <span style="color:rgb(156,220,254)">$USERNAME</span> <span style="color:rgb(156,220,254)">&&</span> <span style="color:rgb(86,156,214)">\</span></div><div>    <span style="color:rgb(156,220,254)">mkdir</span> <span style="color:rgb(156,220,254)">-p</span> <span style="color:rgb(156,220,254)">/etc/sudoers.d</span> <span style="color:rgb(156,220,254)">&&</span> <span style="color:rgb(86,156,214)">\</span></div><div>    <span style="color:rgb(156,220,254)">echo</span> <span style="color:rgb(156,220,254)">$USERNAME</span> <span style="color:rgb(156,220,254)">ALL=\(root\)</span> <span style="color:rgb(156,220,254)">NOPASSWD:ALL</span> <span style="color:rgb(156,220,254)">></span> <span style="color:rgb(156,220,254)">/etc/sudoers.d/</span><span style="color:rgb(156,220,254)">$USERNAME</span> <span style="color:rgb(156,220,254)">&&</span> <span style="color:rgb(86,156,214)">\</span></div><div>    <span style="color:rgb(156,220,254)">chmod</span> <span style="color:rgb(156,220,254)">0440</span> <span style="color:rgb(156,220,254)">/etc/sudoers.d/</span><span style="color:rgb(156,220,254)">$USERNAME</span></div><br><div><span style="color:rgb(197,134,192)">USER</span> <span style="color:rgb(156,220,254)">${USER_UID}</span><span style="color:rgb(156,220,254)">:</span><span style="color:rgb(156,220,254)">${USER_GID}</span></div><br><div><span style="color:rgb(197,134,192)">WORKDIR</span> <span style="color:rgb(156,220,254)">${WDIR}</span></div><br><div><span style="color:rgb(197,134,192)">RUN</span> <span style="color:rgb(156,220,254)">stack</span> <span style="color:rgb(156,220,254)">update</span> </div><br><div><span style="color:rgb(106,153,85)"># Add just the .cabal file to capture dependencies</span></div><div><span style="color:rgb(197,134,192)">COPY</span> <span style="color:rgb(156,220,254)">./package.yaml</span> <span style="color:rgb(156,220,254)">${WDIR}</span><span style="color:rgb(156,220,254)">/package.yaml</span></div><div><span style="color:rgb(197,134,192)">COPY</span> <span style="color:rgb(156,220,254)">./stack.yaml</span> <span style="color:rgb(156,220,254)">${WDIR}</span><span style="color:rgb(156,220,254)">/stack.yaml</span></div><br><div><span style="color:rgb(106,153,85)"># Docker will cache this command as a layer, freeing us up to</span></div><div><span style="color:rgb(106,153,85)"># modify source code without re-installing dependencies</span></div><div><span style="color:rgb(106,153,85)"># (unless one of the copied files changes!)</span></div><div><span style="color:rgb(197,134,192)">RUN</span> <span style="color:rgb(156,220,254)">stack</span> <span style="color:rgb(156,220,254)">build</span> <span style="color:rgb(156,220,254)">--only-dependencies</span> <span style="color:rgb(156,220,254)">-j4</span></div><br><div><span style="color:rgb(197,134,192)">COPY</span> <span style="color:rgb(156,220,254)">.</span> <span style="color:rgb(156,220,254)">${WDIR}</span></div><br><div><span style="color:rgb(197,134,192)">ENV</span> <span style="color:rgb(156,220,254)">DEBIAN_FRONTEND</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">dialog</span><br></div><br><div><span style="color:rgb(197,134,192)">ENTRYPOINT</span> <span style="color:rgb(156,220,254)">[</span><span style="color:rgb(206,145,120)">"/bin/bash"</span><span style="color:rgb(156,220,254)">]</span></div></div></div><div><br></div><div><br></div><div>The above image is built and pushed to dockerhub. Then, in the vscode project, I have a .devcontainer directory with the following Dockerfile:</div><div><br></div><div><div style="color:rgb(204,204,204);background-color:rgb(31,31,31);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(197,134,192)">FROM</span> <span style="color:rgb(78,201,176)">ampersandtarski/ampersand-devcontainer</span>:<span style="color:rgb(156,220,254)">latest</span></div><br><div><span style="color:rgb(197,134,192)">ENV</span> <span style="color:rgb(156,220,254)">DEBIAN_FRONTEND</span><span style="color:rgb(212,212,212)">=</span><span style="color:rgb(156,220,254)">dialog</span></div><br><div><span style="color:rgb(197,134,192)">ENTRYPOINT</span> <span style="color:rgb(156,220,254)">[</span><span style="color:rgb(206,145,120)">"/bin/bash"</span><span style="color:rgb(156,220,254)">]</span></div></div></div><div><br></div><div>The idea is that all the building of the dependencies is already done in the first image. That takes a lot of time, so this is supposed to be a great timesaver (though the image itself is huge). </div><div>However, when I open the project inside the container, I get the following error:</div><div><img src="cid:ii_lkfroezy0" alt="image.png" width="382" height="120"><br></div><div><br></div><div>If I reload the window, I get the following errors:</div><div><img src="cid:ii_lkfrvnjn1" alt="image.png" width="405" height="231"><br></div><div><br></div><div>Long story short, I am not sure how to use the official Haskell image for development in my project. I must be missing something. I have been trying lots of things, but without succes. I hope it is possible to have an image built on top of the official Haskell file that contains all prebuilt dependencies of my project. Are my expectations realistic? If so, what am I missing?</div><div>Any help is much appreciated.</div><div> </div></div>