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
ENV LANG C.UTF-8

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

RUN mkdir /app
WORKDIR /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 manage.py collectstatic --noinput

EXPOSE 8000

Here’s my Procfile:

web: gunicorn api.wsgi -b 0.0.0.0:8000 --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 = []

[env]
  DEBUG = "False"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  internal_port = 8000
  protocol = "tcp"

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

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
#    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?

Thanks!

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", "0.0.0.0:8000", "--access-logfile", "-"]

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

[deploy]
  release_command = "bundle exec rake db:migrate"
2 Likes

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