Search code examples
pythondjangodockerfig

Fig Python 3 Compatible?


I have a django app running python 3.4 and I want to use Fig to help set up dockerized containers for my application's components. When I run fig up I get the following error:

Recreating app_db_1...
Recreating app_search_1...
Creating app_web_1...
Traceback (most recent call last):
  File "/usr/local/Cellar/fig/1.0.1/libexec/bin/fig", line 9, in <module>
    load_entry_point('fig==1.0.1', 'console_scripts', 'fig')()
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/cli/main.py", line 31, in main
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/cli/docopt_command.py", line 21, in sys_dispatch
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/cli/command.py", line 28, in dispatch
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/cli/docopt_command.py", line 24, in dispatch
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/cli/command.py", line 56, in perform_command
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/cli/main.py", line 427, in up
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/project.py", line 174, in up
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/service.py", line 199, in recreate_containers
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/service.py", line 176, in create_container
  File "/usr/local/Cellar/fig/1.0.1/lib/python2.7/site-packages/fig-1.0.1-py2.7.egg/fig/service.py", line 370, in _get_container_create_options
TypeError: unhashable type: 'dict'

Is this because of incompatibilities with Python 3? I.e. is there any way that I can use fig to help build my app, or am I out of luck? Fig was installed using homebrew.

Here's my fig file:

db:
    image: kartoza/postgis
web:
    build: .
    command: python manage.py runserver:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    links:
      - db
      - search
    environment:
      - ALLOWED_HOSTS:
      - STRIPE_CLIENT_ID:
      - STRIPE_CLIENT_SECRET:
      - GOOGLE_API_KEY:
search:
    image: dockerfile/elasticsearch
    links:
      - db

Solution

  • Turns out the problem was not with the version of Python, but with my fig file.

    Fig file should not have dashes in front of environment variables. Corrected fig file is as follows:

    db:
        image: kartoza/postgis
    web:
        build: .
        command: python manage.py runserver:8000
        volumes:
          - .:/code
        ports:
          - "8000:8000"
        links:
          - db
          - search
        environment:
          ALLOWED_HOSTS:
          STRIPE_CLIENT_ID:
          STRIPE_CLIENT_SECRET:
          GOOGLE_API_KEY:
    search:
        image: dockerfile/elasticsearch
        links:
          - db
    

    Fig is a tool written in Python 2.7, and is not available in a Python 3 variety, but that does not mean it is incompatible with Python 3 projects because it is not integrated into the project code. It is a separate tool and is run on its own by python 2.7.