force recognizing a Django build during fly launch?

My first tries at using fly.io. When I try to launch my existing django app, I get a “detected a dockerfile app”. And if I delete my existing dockerfile, and use flyctl launch, it is “detected a python app”. I’m currently assuming that this will give me an incorrect configuration that may cause other problems.
thanks

The Django scanner looks for a requirements.txt file with django or Django in it: flyctl/django.go at master · superfly/flyctl · GitHub

If it doesn’t find that, it checks for one of either requirements.txt, environment.yml, poetry.lock, or Pipfile to detect a Python app: flyctl/python.go at master · superfly/flyctl · GitHub

It seems like you may not be using requirements.txt to manage a Django dependency. You can probably create a stub requirements.txt like this to get the scanner to do the right thing:

# Django

Also, feel free to create a flyctl issue if you’re using some other dependency manager + Django. I’m sure @katia would like to see different setups.

1 Like

I do have django in my requirements.txt file, here is the contents:

-i https://pypi.org/simple
asgiref==3.6.0
backports.zoneinfo==0.2.1; python_version < '3.9'
boto3==1.26.40
botocore==1.29.40
certifi==2022.12.7
dj-database-url==1.2.0
dj-email-url==1.0.6
django-appconf==1.0.5
django-cache-url==3.4.4
django-crispy-forms==1.14.0
django-debug-toolbar==3.8.1
django-dirtyfields==1.9.0
django-filter==22.1
django-pymemcache==1.0.0
django-select2==8.0.0
django-sendgrid-v5==1.2.2
django-ses==3.3.0
django==4.1.4
environs[django]==9.3.3
factory-boy==3.2.1
faker==15.3.4
gunicorn==20.1.0
importlib-metadata==5.2.0; python_version < '3.10'
jmespath==1.0.1
markdown==3.4.1
marshmallow==3.19.0
packaging==22.0
psycopg2-binary==2.9.1
pymemcache==4.0.0
python-dateutil==2.8.2
python-decouple==3.6
python-dotenv==0.21.0
python-http-client==3.3.7
python-memcached==1.59
pytz==2022.7
s3transfer==0.6.0
sendgrid==6.8.1
sentry-sdk==1.12.1
six==1.16.0
sqlparse==0.4.3
starkbank-ecdsa==2.0.3
tzdata==2022.7; sys_platform == 'win32'
urllib3==1.26.13; python_version >= '3.6'
whitenoise==5.3.0
xlsxwriter==3.0.4
zipp==3.11.0

I can create a flyctl issue since I use a pipfile, which probably isn’t uncommon in Django (if I understood you correctly about pipfile being a depedency manager).

I’m curious. You have a Pipfile and a requirements.txt file?

It would not be difficult to change flyctl’s django scanner to check for that file too. Meanwhile the current scanner is very straightforward and should have worked with the requirements.txt file you posted - presuming that file is present, by that name, and in the root directory of your project. Can you verify that that is the case?

Yes, I definitely have a requirements.txt file in my root folder. I use pipenv, hence the pipfile. I thought that I needed a requirements.txt file so I created it (pipenv requirements > requirements.txt). I’ve tried flyctl launch with just the requirements.txt, with just the pipenv/pipenv.lock, and with both. It’s always recognized as a python app.

If I restore my Dockerfile (I use docker on my dev machine), flyctl recognizes the source code as a dockerfile app.

Here’s what I am seeing:

I could create a new account and try again. AFAIK there is nothing else I can do on my end.

Your requirements.txt is bigger than mine. I copy/pasted what you posted. Also check your flyctl version?

I just checked my flyctl version, it is the same as yours. I don’t know why there are different file sizes. I just copied/pasted from my post above and saved, and I get the same length 2160.

Almost exactly twice the size of mine. I likely added a CRLF at the end of my file.

By any chance do you use VSCode, and can you verify that it indicates UTF-8 in the lower right when viewing that file? If it says UTF-16 that would explain why the scanner didn’t find the text.

Also, if you post your Pipfile, I’ll try to reproduce your steps.

It was UTF-16. I changed it to UTF-8 and things have improved. The launch recognizes the Django app. The deploy fails with “Error release command failed, deployment aborted”. I think it is failing after trying to run python manage.py migrate as root. I’ll play with this for a bit and if needed I will make a new post about it.

What encoding is your Pipfile?

The Pipfile is UTF-8. Here is the Pipfile if you are interested.
It just dawned on me that the the requirements.txt file created by pipenv includes more entries. I don’t know if this is important or not.

Thanks!

I’ve opened update fileContains in scanner/helper.go to handle files encoded in UTF-16 · Issue #1925 · superfly/flyctl · GitHub and have Django scanner detect and support Pipfiles · Issue #1926 · superfly/flyctl · GitHub to track the necessary fixes.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.