From 33d2648637e799ed7544b641e26f80cb615adeaf Mon Sep 17 00:00:00 2001 From: George Mamais Date: Sat, 14 Dec 2024 18:25:58 +0000 Subject: [PATCH] fix build in github --- .github/workflows/asn1scc-tests.yml | 2 +- Dockerfile | 12 +------ Dockerfile.local.wsl | 46 +++++++++++++++++++++++++++ github-build.sh | 6 ---- run-local-build-using-docker-image.sh | 2 +- 5 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 Dockerfile.local.wsl diff --git a/.github/workflows/asn1scc-tests.yml b/.github/workflows/asn1scc-tests.yml index 047d561c0..3c1ebd7e3 100644 --- a/.github/workflows/asn1scc-tests.yml +++ b/.github/workflows/asn1scc-tests.yml @@ -21,4 +21,4 @@ jobs: run: chmod +x ./github-build.sh - name: Run container to build and test - run: docker run --rm -v ${{ github.workspace }}:/app --user 1000:1000 asn1scc bash -c "./github-build.sh" + run: docker run --rm -v ${{ github.workspace }}:/app asn1scc bash -c "./github-build.sh" diff --git a/Dockerfile b/Dockerfile index 5767772c3..444356b63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,22 +16,14 @@ RUN set -xe \ && apt-get purge --auto-remove \ && apt-get clean -# Create a non-root user -RUN adduser --disabled-password --gecos '' --uid 1000 myuser -# Adjust permissions for volumes -RUN mkdir -p /workdir /app && chown -R myuser:myuser /workdir /app - -# Switch to the non-root user -USER myuser # Install SDKMAN RUN curl -s "https://get.sdkman.io" | bash && \ echo "source $HOME/.sdkman/bin/sdkman-init.sh" >> $HOME/.bashrc && \ 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" -# Install GNAT and SPARK from AdaCore (still as root since no SDKMAN required here) -USER root +# Install GNAT and SPARK from AdaCore WORKDIR /gnat_tmp/ RUN wget -O gnat-2021-x86_64-linux-bin https://community.download.adacore.com/v1/f3a99d283f7b3d07293b2e1d07de00e31e332325?filename=gnat-2021-20210519-x86_64-linux-bin \ && git clone /~https://github.com/AdaCore/gnat_community_install_script.git \ @@ -40,7 +32,5 @@ RUN wget -O gnat-2021-x86_64-linux-bin https://community.download.adacore.com/v1 && gnat_community_install_script/install_package.sh ./gnat-2021-x86_64-linux-bin /opt/GNAT/gnat-x86-2021 \ && rm -rf /gnat_tmp/ -# Set back to the non-root user for remaining tasks -USER myuser WORKDIR /app/ ENV PATH="/opt/GNAT/gnat-x86-2021/bin:${PATH}" diff --git a/Dockerfile.local.wsl b/Dockerfile.local.wsl new file mode 100644 index 000000000..5767772c3 --- /dev/null +++ b/Dockerfile.local.wsl @@ -0,0 +1,46 @@ +#FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +FROM ubuntu:20.04 + +#install .net +RUN apt-get update && apt-get install -y wget apt-transport-https && \ + wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb && \ + dpkg -i packages-microsoft-prod.deb && \ + apt-get update && apt-get install -y dotnet-sdk-9.0 + +# Install system dependencies +RUN set -xe \ + && DEBIAN_FRONTEND=noninteractive apt-get update -y \ + && apt-get install -y libfontconfig libdbus-1-3 libx11-6 libx11-xcb-dev cppcheck htop \ + python3 python3-distutils gcc g++ make nuget libgit2-dev libssl-dev curl wget git unzip zip \ + && rm -rf /var/lib/apt/lists/* \ + && apt-get purge --auto-remove \ + && apt-get clean + +# Create a non-root user +RUN adduser --disabled-password --gecos '' --uid 1000 myuser + +# Adjust permissions for volumes +RUN mkdir -p /workdir /app && chown -R myuser:myuser /workdir /app + +# Switch to the non-root user +USER myuser + +# Install SDKMAN +RUN curl -s "https://get.sdkman.io" | bash && \ + echo "source $HOME/.sdkman/bin/sdkman-init.sh" >> $HOME/.bashrc && \ + 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" + +# Install GNAT and SPARK from AdaCore (still as root since no SDKMAN required here) +USER root +WORKDIR /gnat_tmp/ +RUN wget -O gnat-2021-x86_64-linux-bin https://community.download.adacore.com/v1/f3a99d283f7b3d07293b2e1d07de00e31e332325?filename=gnat-2021-20210519-x86_64-linux-bin \ + && git clone /~https://github.com/AdaCore/gnat_community_install_script.git \ + && chmod +x gnat_community_install_script/install_package.sh \ + && chmod +x gnat-2021-x86_64-linux-bin \ + && gnat_community_install_script/install_package.sh ./gnat-2021-x86_64-linux-bin /opt/GNAT/gnat-x86-2021 \ + && rm -rf /gnat_tmp/ + +# Set back to the non-root user for remaining tasks +USER myuser +WORKDIR /app/ +ENV PATH="/opt/GNAT/gnat-x86-2021/bin:${PATH}" diff --git a/github-build.sh b/github-build.sh index 7f0d3c707..e81b7cbac 100644 --- a/github-build.sh +++ b/github-build.sh @@ -1,11 +1,5 @@ #!/bin/bash -# Fix ownership of /app -chown -R myuser:myuser /app - -# Ensure HOME is set correctly for sdkman -export HOME=/home/myuser - # Source sdkman initialization script source "$HOME/.sdkman/bin/sdkman-init.sh" diff --git a/run-local-build-using-docker-image.sh b/run-local-build-using-docker-image.sh index 9aca65b2e..a4f92e544 100644 --- a/run-local-build-using-docker-image.sh +++ b/run-local-build-using-docker-image.sh @@ -1,3 +1,3 @@ #!/bin/bash -#docker build -t asn1scc . +#docker build -f Dockerfile.local.wsl -t asn1scc . docker run -ti --rm -v $(pwd):/app -v asn1scc_workdir:/workdir asn1scc bash -c "./local-build.sh $(git rev-parse --abbrev-ref HEAD)"