Django Rest Framework - Not deploying w/ Procfile

Hey there,

I am trying to deploy a DRF app using fly. Here is my Dockerfile:

FROM python:3.10.0-slim-buster

RUN apt-get -y update && apt-get -y autoremove

RUN mkdir /app

RUN apt-get install -y python python-pip python-dev

ADD requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt
ADD . /app
RUN python collectstatic --noinput


Here’s my Procfile:

web: gunicorn api.wsgi -b --access-logfile -

Here’s my fly.toml:

# fly.toml file generated for ssapi on 2021-12-19T15:00:01-05:00

app = "ssapi"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

  DEBUG = "False"

  allowed_public_ports = []
  auto_rollback = true

  internal_port = 8000
  protocol = "tcp"

#  [[services.http_checks]]
#    interval = "15s"
#    grace_period = "5s"
#    method = "get"
#    path = "/"
#    protocol = "http"
#    timeout = "2s"
#    tls_skip_verify = false

    hard_limit = 25
    soft_limit = 20
    type = "connections"

    handlers = ["http"]
    port = 80

    handlers = ["tls", "http"]
    port = 443

#    grace_period = "1s"
    interval = "15s"
 #   restart_limit = 0
    timeout = "2s"

I’m not getting any log output from fly logs. I would expect the Procfile to run gunicorn here. I also added the gunicorn line to my Dockerfile under CMD and it works. What am I missing with the Procfile here?

Also, is there a way to have different deploy commands? For example if I want to deploy the image vs run a Database migration?


The Procfile won’t have any effect when you’re using a Dockerfile, unless you do something special to handle a Procfile. The simplest thing to do here might be to add the CMD to your Dockerfile directly:

CMD ["gunicorn", "api.wsgi", "-b", "", "--access-logfile", "-"]

You can specify a release command in your fly.toml like this:

  release_command = "bundle exec rake db:migrate"

Thank you! This is what I figured. I have seem to overcomplicated the situation :slight_smile: