Few months ago AWS Codebuild used to build docker file successfully. Now after new changes I pushed the build and tried to build and it doesn't work. The build logs shows the following error:
Processing triggers for libc-bin (2.36-9+deb12u7) ...
Removing intermediate container 59eb038789d6
---> 4d864f03be13
Step 6/27 : RUN pip3 install --upgrade pip
---> Running in 7921c1b93c88
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.11/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
The command '/bin/sh -c pip3 install --upgrade pip' returned a non-zero code: 1
Here is the Docker file content which used to build before but not now:
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
RUN apt-get update -y && apt-get -y upgrade && \
apt-get install -y --no-install-recommends python3-pip python3-dev build-essential
RUN pip3 install --upgrade pip
RUN pip3 install --upgrade setuptools && pip3 install awscli
COPY Backend/Deploy/entrypoint.sh .
RUN chmod +x entrypoint.sh
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY Backend/Api/Api.csproj Backend/Api/
COPY Shared/Api.DTO/Api.DTO.csproj Shared/Api.DTO/
COPY Backend/Backend.Core/Backend.Core.csproj Backend/Backend.Core/
COPY Backend/Database.Core/Database.Core.csproj Backend/Database.Core/
COPY Backend/Database.Enums/Database.Enums.csproj Backend/Database.Enums/
COPY Shared/Backend.SharedLogic/Backend.SharedLogic.csproj Shared/Backend.SharedLogic/
RUN dotnet restore "Backend/Api/Api.csproj"
COPY . .
WORKDIR "/src/Backend/Api"
RUN dotnet build "Api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Api.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["./entrypoint.sh", "dotnet", "Api.dll"]