skip to Main Content

So I have a flask application using langchain that I’ve been trying to deploy on heroku. The thing is, the docker image builds and runs perfectly fine without the heroku deployment, I only run into issues when deploying to heroku. I followed these instructions:

  1. Login to heroku: heroku login
  2. Login to heroku container: heroku container:login
  3. Go to flask directory with dockerfile and run: heroku container:push web --app <app-name>

When I run step 3, I keep getting this error:

[+] Building 2.1s (12/12) FINISHED                                docker:desktop-linux
 => [internal] load build definition from Dockerfile                              0.0s
 => => transferring dockerfile: 226B                                              0.0s
 => resolve image config for docker-image://docker.io/docker/dockerfile:1         0.8s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:865e5dd094beca432  0.0s
 => => resolve docker.io/docker/dockerfile:1@sha256:865e5dd094beca432e8c0a1d5e1c  0.0s
 => [internal] load metadata for docker.io/library/python:3.12-slim               0.8s
 => [internal] load .dockerignore                                                 0.0s
 => => transferring context: 2B                                                   0.0s
 => [1/5] FROM docker.io/library/python:3.12-slim@sha256:af4e85f1cac90dd3771e472  0.0s
 => => resolve docker.io/library/python:3.12-slim@sha256:af4e85f1cac90dd3771e472  0.0s
 => [internal] load build context                                                 0.0s
 => => transferring context: 93B                                                  0.0s
 => CACHED [2/5] WORKDIR /test                                                    0.0s
 => CACHED [3/5] COPY requirements.txt requirements.txt                           0.0s
 => CACHED [4/5] RUN pip install -r requirements.txt                              0.0s
 => CACHED [5/5] COPY . .                                                         0.0s
 => exporting to image                                                            0.1s
 => => exporting layers                                                           0.0s
 => => exporting manifest sha256:8e61290c43414b6925441272dc06f4f0a4f23b5c5de7755  0.0s
 => => exporting config sha256:0931ca17cf70351a4cef92bbdfac6230b22c455c17544e2ac  0.0s
 => => exporting attestation manifest sha256:44105731c3395578fbc710ba7d7828abd44  0.0s
 => => exporting manifest list sha256:5bd92a0f9fc31324aab464d82285036b61a2132a53  0.0s
 => => naming to registry.heroku.com/indic-power/web:latest                       0.0s
 => => unpacking to registry.heroku.com/indic-power/web:latest                    0.0s
=== Pushing web (C:UsersPhotogaugeDesktoprahuldockertestDockerfile)

Using default tag: latest
The push refers to repository [registry.heroku.com/indic-power/web]
b91db956ff46: Pushed
6b08635bc459: Layer already exists
23acc3c7fc2a: Pushed
c8daa4e2ec2f: Pushed
8341816e3d13: Layer already exists
302e3ee49805: Layer already exists
38732fc0313c: Pushed
0bc61d7a3c35: Pushed
18bb7c8edce2: Layer already exists
failed commit on ref "manifest-sha256:8e61290c43414b6925441272dc06f4f0a4f23b5c5de775529a798ccda90ce0d2": unexpected status from PUT request to https://registry.heroku.com/v2/indic-power/web/manifests/latest: 405 Method Not Allowed
 ยป   Error: docker push exited with Error: 1

This is my dockerfile:

#syntax=docker/dockerfile:1
FROM python:3.12-slim

WORKDIR /power

COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY data/ data/

COPY . .

CMD [ "python", "api.py"]

and my docker-compose.yaml:

version: '2'
services:
  web:
    build: .
    ports: 
      - "5000:5000"
    volumes:
      - .:/app
    working_dir: /app
    command: python api.py
    env_file:
      - .env

I’ve tried clearing the docker cache with

docker builder prune
docker system prune -a

but it makes no difference. What am I doing wrong?

2

Answers


  1. The issue is BuildKit 0.11 enabling "provenance" by default, see: https://help.heroku.com/74S3XXMP/workaround-for-docker-push-error-405-method-not-allowed-using-buildkit-0-11

    The solution depends on where you are pushing the image form. For example, with Github action build-push-action you can do:

    - name: Docker build
      uses: docker/build-push-action@v3
      with:
        provenance: false
    
    Login or Signup to reply.
  2. A quick fix for me is to use an older docker version 4.8.2 or any other where enabling "provenance" is not default

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search