Service 'web' failed to build with Protocol error

I am trying to use postgresql in the docker container. However, i get an error

Service ‘web’ failed to build: The command ‘/bin/sh -c apk add --update --no-cache --virtual .tmp-build-deps gcc libc-dev linux-headers postgresql-dev musl-dev zlib zlib-dev’ returned a non-zero code: 4

I get other related issue like ERROR: mpfr3-3.1.5-r1: Protocol error.

Here is the screenshot of an issue as well as this might be related to each other

Here is the source code

FROM python:3.7-alpine

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1

# set working directory which will be inside ubuntu
WORKDIR /code

#### Install a dependency ####
# Copies new files and resources to the image's filesystems
RUN pip3 install pipenv
COPY Pipfile Pipfile.lock /code/
RUN apk add --update --no-cache postgresql-client jpeg-dev
RUN apk add --update --no-cache --virtual .tmp-build-deps \
    gcc libc-dev linux-headers postgresql-dev musl-dev zlib zlib-dev
RUN pipenv install --system
RUN apk del .tmp-build-deps
COPY . /code/

RUN adduser -D user
USER user

docker-compose.yml

version: "3.7"

services:
  db:
    image: postgres:12-alpine
    environment:
      - POSTGRES_DB=database
      - POSTGRES_USER=admin
      - POSTGRES_PASSWORD=admin123
  web:
    build: .
    command: >
      sh -c "python /code/manage.py wait_for_db &&
             python /code/manage.py runserver 0.0.0.0:8000"
    environment:
      - DB_HOST=db
      - DB_NAME=database
      - DB_USER=admin
      - DB_PASS=admin123
    volumes:
      - .:/code
    # lets us map our port 8000 to the port 8000 in the Docker container
    ports:
      - 8000:8000
    # it says that we should run the db first before running our web services
    depends_on:
      - db