22#
33# Dockerfile to install Copilot and make it available to the user
44#
5- #
6- # This file is specific to versions of Ubuntu strictly before 23.04. After that
7- # version, Copilot became included in Ubuntu as a package.
5+ # This file is designed to support a Docker Build on both AMD64 and ARM64
6+ # systems. As a result, some items are built from source instead of prebuilts.
87#
98FROM ubuntu:focal
109
@@ -14,7 +13,7 @@ ENV DEBIAN_FRONTEND=noninteractive
1413# Install dependencies
1514RUN apt-get update && \
1615 apt-get upgrade -y && \
17- apt-get install -y \
16+ apt-get install -y --no-install-recommends \
1817 build-essential \
1918 cpio \
2019 git \
@@ -33,37 +32,52 @@ RUN apt-get update && \
3332 && \
3433 apt-get -y autoremove && \
3534 apt-get -y clean && \
36- rm -rf /var/lib/apt/lists/*
35+ rm -rf /var/lib/apt/lists/* /usr/share/{icons,alsa,AAVMF,ovmf,fonts,vim,mime,X11,i18n,man,doc}
3736
38- # Install Copilot dependencies
37+ # Build Haskell env from source
38+ ENV BOOTSTRAP_HASKELL_NONINTERACTIVE=1
39+ ENV BOOTSTRAP_HASKELL_VERBOSE=1
40+ ENV BOOTSTRAP_HASKELL_GHC_VERSION=8.6.5
41+ ENV GHCUP_INSTALL_BASE_PREFIX=/opt
3942RUN apt-get update && \
4043 apt-get install -y \
4144 alex \
45+ curl \
4246 happy \
4347 libbz2-dev \
4448 libexpat-dev \
49+ libncurses-dev \
50+ libtinfo5 \
4551 libz-dev \
4652 pkg-config \
4753 software-properties-common \
4854 && \
49- apt-get -y autoremove && \
50- apt-get -y clean && \
51- rm -rf /var/lib/apt/lists/*
52- RUN add-apt-repository ppa:hvr/ghc && \
53- apt-get update && \
54- apt-get install -y \
55- ghc-8.6.5 \
56- cabal-install-2.4 \
55+ curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh && \
56+ ls /opt/.ghcup/bin && /opt/.ghcup/bin/ghcup gc --cache && \
57+ rm -rf /root/.cabal/packages/* /opt/.ghcup/cache/ghc-8.6.5-a /opt/.ghcup/cache/stack* && \
58+ . /opt/.ghcup/env && \
59+ cabal clean && \
60+ echo 'source /opt/.ghcup/env' >> /root/.bashrc && \
61+ apt-get remove -y \
62+ alex \
63+ curl \
64+ happy \
65+ libbz2-dev \
66+ libexpat-dev \
67+ libncurses-dev \
68+ libz-dev \
69+ pkg-config \
70+ software-properties-common \
5771 && \
5872 apt-get -y autoremove && \
5973 apt-get -y clean && \
6074 rm -rf /var/lib/apt/lists/*
61-
75+
6276# To be able to generate a toolchain with locales, enable one UTF-8 locale
6377RUN sed -i 's/# \( en_US.UTF-8\) /\1 /' /etc/locale.gen && \
6478 /usr/sbin/locale-gen
6579
66- # Pass environment variables during build
80+ # Pass environment variables during a build to represent a version
6781ARG CI_COMMIT_SHA="Local"
6882ARG CI_PIPELINE_URL="Local"
6983ARG DOCKERFILE_AUTHOR="Local"
@@ -86,34 +100,59 @@ RUN echo "Creation Date: $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > /.VERSION && \
86100RUN useradd -ms /bin/bash user
87101RUN echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/user \
88102 && chmod 0440 /etc/sudoers.d/user
89- RUN echo 'export PATH= /opt/ghc/8.6.5/bin:/opt/cabal/2.4/bin:/home/user/.cabal/bin/:$PATH ' >> /home/user/.bashrc && \
103+ RUN echo 'source /opt/.ghcup/env ' >> /home/user/.bashrc && \
90104 chown -R user:user /home/user
91- # Transparent uid:gid setup for manual container use
92- COPY entry.sh /entry.sh
93- RUN chmod 777 /entry.sh && chown root:root /entry.sh
94105USER user
95106WORKDIR /home/user
96107
97- # Install Copilot
98- ENV PATH=/opt/ghc/8.6.5/bin:/opt/cabal/2.4/bin:/home/user/.cabal/bin/:$PATH
99- RUN cabal v2-update
100- RUN cabal v2-install --lib \
108+ # Install Copilot - cabal was stable on a small ARM machine with extra args setting limits
109+ # e.g., --jobs=1 --ghc-options="+RTS -M200M -RTS"
110+ RUN sudo apt-get update && \
111+ sudo apt-get install -y \
112+ clang \
113+ libbz2-dev \
114+ libgmp-dev \
115+ lld \
116+ lldb \
117+ llvm \
118+ && \
119+ . /opt/.ghcup/env && \
120+ cabal v2-update && \
121+ cabal v2-install --lib \
101122 copilot-4.5.1 \
102123 copilot-c99-4.5.1 \
103124 copilot-interpreter-4.5.1 \
104125 copilot-language-4.5.1 \
105126 copilot-libraries-4.5.1 \
106- copilot-theorem-4.5.1
107-
108- # Install Ogma
109- RUN cd && \
127+ copilot-theorem-4.5.1 && \
110128 git clone https://github.com/nasa/ogma.git && \
111129 cd ogma && \
112130 cabal v2-install ogma-cli:ogma && \
113- cd && \
114- rm -rf ogma
131+ echo 'export PATH=$HOME/.local/bin/:$PATH' >> /home/user/.bashrc && \
132+ cd .. && \
133+ rm -rf ogma && \
134+ cabal clean && \
135+ rm -rf ~/.cache/cabal/packages/* && \
136+ sudo apt-get remove -y \
137+ clang \
138+ lld \
139+ lldb \
140+ llvm \
141+ && \
142+ sudo apt-get -y autoremove && \
143+ sudo apt-get -y clean && \
144+ sudo rm -rf /var/lib/apt/lists/*
145+
146+ ENV PATH=/home/user/.local/bin/:$PATH
115147
116- # Check that tools seem to run
117- RUN ghci --version && ogma --help
148+ # Check that tools seem to run as normal user
149+ RUN . /opt/.ghcup/env && \
150+ ghci --version && \
151+ cabal --version && \
152+ ogma --help
153+
154+ # Transparent uid:gid setup for manual container use
155+ COPY entry.sh /entry.sh
156+ RUN sudo chmod 777 /entry.sh && sudo chown root:root /entry.sh
118157
119158ENTRYPOINT ["/entry.sh" ]
0 commit comments