1+ # FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
12FROM ubuntu:20.04
23
4+ # install .net
35RUN apt-get update && apt-get install -y wget apt-transport-https && \
46 wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb && \
57 dpkg -i packages-microsoft-prod.deb && \
68 apt-get update && apt-get install -y dotnet-sdk-9.0
79
8-
10+ # Install system dependencies
911RUN set -xe \
1012 && DEBIAN_FRONTEND=noninteractive apt-get update -y \
11- && apt-get install -y libfontconfig libdbus-1-3 libx11-6 libx11-xcb-dev cppcheck htop \
12- python3 python3-distutils gcc g++ make nuget libgit2-dev libssl-dev git \
13+ && apt-get install -y libfontconfig libdbus-1-3 libx11-6 libx11-xcb-dev cppcheck htop \
14+ python3 python3-distutils gcc g++ make nuget libgit2-dev libssl-dev curl wget git unzip zip \
1315 && rm -rf /var/lib/apt/lists/* \
1416 && apt-get purge --auto-remove \
1517 && apt-get clean
1618
17- # this SHELL command is needed to allow using source
18- SHELL ["/bin/bash" , "-c" ]
19- # Install dependencies for scala backend
20- RUN apt-get update -y \
21- && apt-get install -y curl wget unzip zip \
22- && curl -s "https://get.sdkman.io" | bash \
23- && chmod a+x "$HOME/.sdkman/bin/sdkman-init.sh" \
24- && source "$HOME/.sdkman/bin/sdkman-init.sh" \
25- && sdk install java 17.0.9-oracle \
26- && sdk install scala 3.3.0 \
27- && sdk install sbt 1.9.0
28-
29- # Install GNAT AND SPARK from AdaCore
30- WORKDIR /gnat_tmp/
19+ # Create a non-root user
20+ RUN adduser --disabled-password --gecos '' --uid 1000 myuser
3121
32- # The ADD instruction will always download the file and the cache will be invalidated if the checksum of the file no longer matches
33- # On the other hand, the RUN instruction will not invalidate the cache unless its text changes.
34- # So if the remote file is updated, you won't get it. Docker will use the cached layer.
35- # In our case, the gnat-2021-20210519-x86_64-linux-bin will not change. So, it is preferable to ADD
36- # ADD https://community.download.adacore.com/v1/f3a99d283f7b3d07293b2e1d07de00e31e332325?filename=gnat-2021-20210519-x86_64-linux-bin ./gnat-2021-20210519-x86_64-linux-bin
37-
38- RUN wget -O gnat-2021-20210519-x86_64-linux-bin https://community.download.adacore.com/v1/f3a99d283f7b3d07293b2e1d07de00e31e332325?filename=gnat-2021-20210519-x86_64-linux-bin \
39- && git clone https://github.com/AdaCore/gnat_community_install_script.git \
40- && chmod +x gnat_community_install_script/install_package.sh \
41- && chmod +x gnat-2021-20210519-x86_64-linux-bin \
42- && gnat_community_install_script/install_package.sh ./gnat-2021-20210519-x86_64-linux-bin /opt/GNAT/gnat-x86-2021 \
43- && cd \
44- && rm -rf /gnat_tmp/ \
45- && sed -i 's/# alias l=/alias l=/' ~/.bashrc \
46- && sed -i 's/# export LS_OPTIONS/export LS_OPTIONS/' ~/.bashrc
22+ # Adjust permissions for volumes
23+ RUN mkdir -p /workdir /app && chown -R myuser:myuser /workdir /app
4724
48- WORKDIR /app/
25+ # Switch to the non-root user
26+ USER myuser
4927
28+ # Install SDKMAN
29+ RUN curl -s "https://get.sdkman.io" | bash && \
30+ echo "source $HOME/.sdkman/bin/sdkman-init.sh" >> $HOME/.bashrc && \
31+ bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk install java 17.0.9-oracle && sdk install scala 3.3.0 && sdk install sbt 1.9.0"
32+
33+ # Install GNAT and SPARK from AdaCore (still as root since no SDKMAN required here)
34+ USER root
35+ WORKDIR /gnat_tmp/
36+ RUN wget -O gnat-2021-x86_64-linux-bin https://community.download.adacore.com/v1/f3a99d283f7b3d07293b2e1d07de00e31e332325?filename=gnat-2021-20210519-x86_64-linux-bin \
37+ && git clone https://github.com/AdaCore/gnat_community_install_script.git \
38+ && chmod +x gnat_community_install_script/install_package.sh \
39+ && chmod +x gnat-2021-x86_64-linux-bin \
40+ && gnat_community_install_script/install_package.sh ./gnat-2021-x86_64-linux-bin /opt/GNAT/gnat-x86-2021 \
41+ && rm -rf /gnat_tmp/
42+
43+ # Set back to the non-root user for remaining tasks
44+ USER myuser
45+ WORKDIR /app/
5046ENV PATH="/opt/GNAT/gnat-x86-2021/bin:${PATH}"
51- # ENTRYPOINT ["/bin/bash"]
0 commit comments