Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only Mount Specific File Extensions #346

Closed
saulshanabrook opened this issue Jul 24, 2014 · 3 comments
Closed

Only Mount Specific File Extensions #346

saulshanabrook opened this issue Jul 24, 2014 · 3 comments

Comments

@saulshanabrook
Copy link

I am not sure if this is possible, but I am wondering if it would be possible to mount only, say, *.py files with the volumes part of the fig.yml.

I am trying to mount a directory that has a python package in it. My Dockefile looks like this:

FROM python:3

ADD . /code/
WORKDIR /code
RUN pip install -r requirements-testing.txt -e .

ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

The problem is that when I have a fig.yml like this:

python:
  build: .
  volumes:
    - .:/code/

And then run try to run the CLI installed with my Python app, it doesn't work, because pip install -e . creates some directories with the built python package under /code/. Then when I mount my local source code directory over that directory, it removes those build directory and the command fails.

$ fig run python dc-campaign-finance-scraper
Traceback (most recent call last):
  File "/usr/local/bin/dc-campaign-finance-scraper", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.4/site-packages/pkg_resources.py", line 2697, in <module>
    working_set.require(__requires__)
  File "/usr/local/lib/python3.4/site-packages/pkg_resources.py", line 669, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.4/site-packages/pkg_resources.py", line 572, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: dc-campaign-finance-scraper==0.5.1

So if I could only mount .py files, it wouldn't overwrite all that other stuff. I am not sure if this is remotely possible, and if not, whether you have any tips using fig for python package development/

@aanand
Copy link

aanand commented Jul 25, 2014

This isn't possible with Docker volumes, I'm afraid.

Is it possible to get pip install to put the files in a different directory, outside /code, and configure Python to look there? Glancing over the Pip docs, it looks like --root or --target might do the trick.

@saulshanabrook
Copy link
Author

The best solution I found was only mounting the actual code and tests directories, and leaving the other files untouched.

This way source files will be updated without rebuilding, but it will not overwrite the compiled files.

python:
  build: .
  volumes:
    - dc_campaign_finance_scraper:/code/dc_campaign_finance_scraper
    - test:/code/test

@foxx
Copy link

foxx commented Feb 17, 2018

This was driving me crazy for hours, thank you @saulshanabrook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants