I’m trying to install my python packages on a volume because they’re large (i.e. almost larger than 8GB, which appears to be the current limit). To do this, I’m trying to use use an entrypoint.sh
file for my docker image. The goal is to install them on start, before running the app, but (due to the volume persistent) they’ll be cached there in the future:
#!/bin/bash
whoami # root at this point
mkdir /python_packages/cache
mkdir /python_packages/packages
/usr/bin/python3 -m pip install -U -r requirements.txt --target /python_packages/packages --cache-dir /python_packages/cache
chown nobody -R /python_packages/
export PYTHONPATH="${PYTHONPATH}:/python_packages/packages"
# run app as nobody
runuser -u nobody /app/bin/server
I’ve also created a volume with fly volumes create python_packages --region ewr --size 10
. Output of fly volumes list
:
ID STATE NAME SIZE REGION ZONE ENCRYPTED ATTACHED VM CREATED AT
vol_p4mwmpze39321jdr created python_packages 10GB ewr 732d true 148eddd4f471e8 20 hours ago
However! During deploy it looks like the volume is not yet mounted when entrypoint.sh
runs. In the logs I see this:
bos [info]mkdir: cannot create directory ‘/python_packages/cache’: No such file or directory
bos [info]mkdir: cannot create directory ‘/python_packages/packages’: No such file or directory
Strangely, the logs then continue to install the python packages:
...
bos [info] Downloading confection-0.1.3-py3-none-any.whl (34 kB)
bos [info]Collecting click<9.0.0,>=7.1.1
bos [info] Downloading click-8.1.7-py3-none-any.whl (97 kB)
bos [info]Collecting MarkupSafe>=2.1.1
bos [info] Downloading MarkupSafe-2.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
bos [info]Building wheels for collected packages: spacy-universal-sentence-encoder, jax
bos [info] Building wheel for spacy-universal-sentence-encoder (setup.py): started
bos [info] Building wheel for spacy-universal-sentence-encoder (setup.py): finished with status 'done'
bos [info] Created wheel for spacy-universal-sentence-encoder: filename=spacy_universal_sentence_encoder-0.4.6-py3-none-any.whl size=16551 sha256=41107463de037206e30a42ddb25d51a51eb589373a2febefeb309351e9db99cb
bos [info] Stored in directory: /python_packages/cache/wheels/23/cf/0b/162118b8e7dac277d8bd91f17dec299c6210e25bdff1a53264
However, when I fly ssh console
into the machine and run ls -l /python_packages
:
root@148eddd4f471e8:/app# ls -l /python_packages/
total 16
drwx------ 2 root root 16384 Sep 10 00:02 lost+found
So, while I’m not sure why pip is happily installing packages anyway, clearly the volume is not available/mounted because A) mkdir
fails with No such file or directory
B) there are no python packages in the volume C) it’s still owned by root at the end.
One thing I noticed is that my app is in ewr
, but the deploy ran from a bos
machine. I’m not really sure what, if anything, that means, but it seemed a bit suspicious.
Any help would be greatly appreciated!