FROM haskell:8.10
ARG USERNAME=vscode
ENV USERNAME=${USERNAME} \
USER_UID=1000 \
USER_GID=1000 \
DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF8 \
WDIR=/home/${USERNAME}
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y git
RUN groupadd --gid $USER_GID $USERNAME && \
useradd -ms /bin/bash -K MAIL_DIR=/dev/null --uid $USER_UID --gid $USER_GID -m $USERNAME && \
mkdir -p /etc/sudoers.d && \
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME
USER ${USER_UID}:${USER_GID}
WORKDIR ${WDIR}
RUN stack update
# Add just the .cabal file to capture dependencies
COPY ./package.yaml ${WDIR}/package.yaml
COPY ./stack.yaml ${WDIR}/stack.yaml
# Docker will cache this command as a layer, freeing us up to
# modify source code without re-installing dependencies
# (unless one of the copied files changes!)
RUN stack build --only-dependencies -j4
COPY . ${WDIR}
ENV DEBIAN_FRONTEND=dialog
ENTRYPOINT ["/bin/bash"]