Adding a font to a docker image - google-app-engine

My company has a docker image which we use for app engine flex. I need to add a font, and there doesn't seem to be a simple apt package anywhere, so I need to add it manually, following steps like the ones listed here for command-line installation on Linux. Here's what I have so far:
FROM gcr.io/google_appengine/python
# ...
# Copy the font to the appropriate location.
# The font is in a ttf in the same directory as the Dockerfile.
RUN mkdir -p /usr/share/fonts/truetype/noto
COPY NotoColorEmoji.ttf /usr/share/fonts/truetype/noto
RUN chmod 644 /usr/share/fonts/truetype/noto/*
# Rebuild the font cache.
RUN fc-cache -fv
As you can see, the image is based on the GAE base python image. We're adding a few other things, as well, but this is the stuff relevant to the font.
The fc-cache output when building the image makes it clear that it is detecting one font in the noto directory:
/usr/share/fonts/truetype/noto: caching, new cache contents: 1 fonts, 0 dirs
And when I log in to a container, I see that the file was indeed copied. I can even run fc-cache again manually and see that same output. The new font, however, is never reflected in fc-list.
It's been frustrating to diagnose this because following similar steps seems to work perfectly on my own machine. It's almost as if fc-cache is behaving differently in the container.
Any ideas on what I might be missing?
Update:
I added a line to the docker file to explicitly set the correct permissions on the font file after copying it, but it made no difference. This was expected because these commands ultimately run as root, but still it seems like a better practice.
Interestingly, though, I tried this with a different font (NotoEmoji-Regular.ttf) and it did work. I'll be looking into what the difference between these two fonts might be that is causing this.
Very frustrating.
Another Update:
It seems the primary difference is likely the colors in the font, which is nonstandard in the TrueType format. As comments have pointed out, my system is using a newer version of fontconfig than the docker image, which likely accounts for the discrepancy.
I'd like to verify this, but it's digging a bit down a rabbit hole that my organization would rather me not spend too much more time on. If anybody is able to do so, however I'd be happy to give you the accepted answer. Otherwise I'm going to have to leave this be for a bit.

Try to add to dockerfile
# install fontconfig
RUN apt-get update; apt-get install -y fontconfig
# refresh system font cache
RUN fc-cache -f -v

it's the font file had issue, check the report in image

I used below commnad inside Docker file to install fonts and that worked for me.
RUN apt update && apt install fonts-indic -y \
&& fc-cache -f
or
RUN apk add font-noto-gujarati font-noto-kannada font-noto-avestan font-noto-osage font-noto-kayahli font-noto-oriya font-noto-telugu font-noto-tamil font-noto-bengali font-noto-malayalam font-noto-arabic font-noto-extra \
&& fc-cache -f
Note: u can add more fonts name based on your requirement.

Related

VOLTTRON install on rasbian buster

Can I get a tip for installing on rasp buster? Im hung up on the install directions to check the status of the rabbitMQ server. Traceback of bash console:
(volttron) pi#raspberry:~/Desktop/volttron $ echo 'export RABBITMQ_HOME=$HOME/rabbitmq_server/rabbitmq_server-3.7.7'|sudo tee --append ~/.bashrc
export RABBITMQ_HOME=$HOME/rabbitmq_server/rabbitmq_server-3.7.7
(volttron) pi#raspberry:~/Desktop/volttron $ source ~/.bashrc
pi#raspberry:~/Desktop/volttron $ RABBITMQ_HOME/sbin/rabbitmqctl status
bash: RABBITMQ_HOME/sbin/rabbitmqctl: No such file or directory
There are a few tracebacks earlier on the installation...
If it makes a difference or not here is the entire bash console process. The git gist link I just created the name install.py even though its just bash commands copied pasted per install directions...
`pi#raspberry:~/Desktop $ git clone https://github.com/VOLTTRON/volttron --branch releases/7.x`
It looks like there are a couple of different issues going on here:
The issue you quote above (RABBITMQ_HOME/sbin/rabbitmqctl: No such file or directory) is that your shell isn't finding the rabbitmqctl command. It looks like you added the RABBITMQ_HOME environment variable to your .bashrc, but used the string RABBITMQ_HOME instead of the variable expansion $RABBITMQ_HOME when you tried to run the command. Try running it as $RABBITMQ_HOME/sbin/rabbitmqctl status instead.
The rabbitmqctl status command will check the status of the rabbitmq application, but I don't think you've done anything to start it yet (that happens when you bootstrap the platform and/or start the platform configured to use the RMQ broker)
I think that the traces earlier in the installation process are problematic (appears to be the same error hit two different ways), but you just haven't run into them yet. I haven't seen any issues building gevent on the RPi 4 with buster (though it is pretty slow), but the ctypes error makes me wonder if there's an issue with the underlying c library it is trying to build on top of. I did notice that you're getting amd64 erlang packages, are you running Raspbian on an x86 processor? (if so this isn't a permutation we've tried and you may be hitting some package compatibility edge case we haven't seen)
One thing to try is to manually install cython into your virtualenvironment and then try running the bootstrap script again with the virtualenvironment activated. You could also try and pip install gevent==20.6.1 directly in that virtualenvironment (this is what the bootstrap script was doing at the failure point). VOLTTRON depends on gevent, so if that isn't installing the platform won't be able to run.

Where can I download mobilenet_v1_160res_0.5_imagenet_labels.txt for local testing?

For our course projects, we started off with Google's AIY Vision kit. I am looking into how to use output for next level processing. We are all newbies to ML
I am testing image classification using sources from Github AIY Projects on my mac.
python image_classification.py -i images/cat01.jpeg
FileNotFoundError: [Errno 2] No such file or directory: '/opt/aiy/models/mobilenet_v1_160res_0.5_imagenet_labels.txt'
I would like to test this to see output format that I want to use for next steps.
Where can I get the labels txt file?
I found a good Coral link that has TPU models and labels. Is there a way to use this instead?
couldn't get it to work on my mac but tried to create a dockerfile for some of the AIY example codes to run on a docker host within the mac.
The missing piece to overcome the error you listed above for me was to :
apt-get install -y aiy-models after adding the Debian repo source. Not sure how to get around that on the mac.

What are dronekit-python dependencies?

The dronekit Getting Started page suggests installing WinPython to use dronekit-Python on Windows because it includes the dependencies. I already have a working Python installation and I prefer not to risk messing it up with WinPython. What are the dependencies I need to install?
As of DKPY 2.0 this is outdated. Also, I might move to making a MavProxy module depending on whether or not the unpaid devs decide to stay when 3DR stops funding Dronekit
I've written a procedure to help with this problem which I've pasted. 3DR claims they're going to fix it, but in the mean time I hope this will help.
This setup is for Windows 64-bit systems only, although similar procedures will work with 32-bit.
Install MAVProxy and run it once before reaching step 5.
Install Notepad++.
Install Python v2.7.
Inside the Python folder, run WinPython Control Panel and select Advanced->Register Python.
Inside the same folder, run WinPython Command Prompt and input the following four commands:
• pip uninstall python-dateutil
• pip install droneapi
• pip install console
• echo module load droneapi.module.api >> %HOMEPATH%\AppData\Local\MAVProxy\mavinit.scr
Install WX Python. It should be the 64-bit Python 2.7 version.
Download and install OpenCV 2.4.11 to any folder
• Copy/paste the file cv2.pyd from OpenCV\build\python\2.7\x64\ to \python-2.7.6.amd64\Lib\site-packages.
Steps 8 through 11 apply to SITL only
Follow the online documentation for setting up Cygwin for SITL in Windows
Go to C:\cygwin\home\Your Username\ardupilot\Tools\autotest\
Open sim_vehicle.sh in Notepad++
• Change line 429 from…
cygstart -w "/cygdrive/c/Program Files (x86)/MAVProxy/mavproxy.exe" $options --cmd="$extra_cmd" $*
to...
cygstart -w "/cygdrive/c/Users/YOUR USERNAME HERE/Desktop/WinPython-64bit-2.7.6.4/python-2.7.6.amd64/Dronekit/Scripts/mavproxy.py" $options --cmd="$extra_cmd" $*
Note: This location changes depending on where you installed WinPython. For me, it was the desktop.
Start simulations as you would normally for SITL. To run Python scripts during the simulations, use the command
• api start Path to script\script_name
To use the code to connect to an actual copter, open WinPython Command Prompt
• Navigate to the folder which contains the scripts you wish to test
• Type mavproxy.py --master=”com##”,57600
• Run your script by typing into the MAVProxy terminal
o api start script_name

Install Packages (for dummies)

I know there's a lot of information on here about installing python packages, but I'm quite new to python and I think I need a more "for dummies" level of help.
I was trying to install openpyxl for which as far as I can tell I need easy_install, for which, as far as I can tell, I need setuptools. I tried running the code provided here https://pypi.python.org/pypi/setuptools which is supposed to download and install setuptools (and according to some sites, easy_install aswell?) - it runs successfully, but help(modules) doesn't show setuptools or easy_install as modules, I have no idea whats installed and what isn't, or how I'm supposed to install any of it!
Essentially I'm very confused, very frustrated and really need someone to talk me through (in idiot-speak) what I'm supposed to do.
Thankyou!
We all start somewhere, I was there two weeks ago.
I'll assume you're using Python2. I believe Distribute and Pip are recommended for Python3 (which I will be using as examples). I will also assume you are on Windows.
First, python needs to be registered to Path. To check if this has been done automatically, open a command prompt (start -> programs -> accessories), and type 'python', then enter. If it returns the version number, etc, skip down a bit. If it throws an error, you need to add Python to Path.
Adding Python to Path
To add Python to Path on a Windows computer, go to:
Control Panel -> System -> Advanced Settings -> Environment Settings -> System Variables
Scroll down to select path, then click edit. Copy the entire line to a text document, and add your install directory for Python.exe (and the scripts folder) using ';' as a delimiter between different directories. Copy this back to Path and save. (Additionally close your command prompt window to reset it.)
For my Windows 7 machine, I added:
;C:\Python33;C:\Python33\scripts;
Take care when editing this file. There are many videos out there describing this in detail if you feel unsure about changing this.
Installing Modules (Such as setup_tools)
Once Python is registered in the Path file, download and unzip setup_tools to a folder within your Python install directory called 'modules'. I use ExtractNow to unzip, as it will unzip twice (as required) automatically.
Open a command prompt window again, and direct it to change directories by typing
cd [directory for module you want to install]
On my computer, this would be
cd C:\Python33\modules\distribute-0.6.40
Again, I use distribute, rather than setup_tools as it sounds like you need would for Python2. Simply use the appropriate directory. Press enter to change the directory.
Once you've entered this and it shows a changed directory, type:
python setup.py install
This indicates that you want to use the program python to use the setup.py file in the specified folder to install the module. This should be successful, and will write many lines of code.
If you want to install other modules, you would install them in a similar way. Python would automatically use setup_tools on your computer to finish each install.
Remember to import at the start of your script when using them to code:
import [module]
Happy Programming!

Wine is extremely slow, how do I find out why?

Recently I updated Wine (among other things) via port selfupdate from version 1.2 to version 1.4. After that it takes roughly a minute to start up, even simple things such as wine cmd or winecfg. CPU usage also spikes to about 140%.
I've tried completely removing and re-installing MacPorts (yes, I removed ~/.wine) and it's still as slow.
How do I get to the bottom of this?
On 2012-03-20 I updated fontconfig to 2.9.0_0; fontconfig is used by wine and other ports to find fonts. Unfortunately there was a problem where fontconfig did not create its cache files correctly, causing it to try to recreate them each time you use a program that uses fontconfig; this could take a minute or more, depending on your disk speed and how many fonts you have installed, since it's indexing all your fonts.
I updated fontconfig to 2.9.0_1 on 2012-03-27 with a patch to fix this so the usual "sudo port selfupdate" and "sudo port upgrade outdated" commands should fix this.

Resources