Fonts and fontspec for compiling latex documents in a docker container - docker

I'm using latex to compile a document but don't want to mess around with installing texlive on my machine again. To that end I've had great luck compiling documents with latex-in-a-docker-container. As a starting point I followed the directions at
https://github.com/James-Yu/LaTeX-Workshop/wiki/Format#LaTeX-files
using the tianon/latex:latest docker image.
However, if I want to use fonts that are installed locally for my document, I run into problems. Some workarounds that I've had some luck with include
1) create a custom Docker image and install each font I may want, individually, e.g. by adding instructions for installing it to the Dockerfile
2) copy the font to my current directory and tell fontspec where to find it
Both of these seem sub-optimal. Ideally I would like to modify my docker run command (see, e.g., https://github.com/Arxisos/LaTex-Workshop-Docker/blob/master/bin/latexmk) so that all my system fonts are copied into the container's /usr/share/fonts directory (I believe this is where the system looks for them -- the Docker image is based on Debian; I'm looking at https://wiki.debian.org/Fonts). Is there a way to copy all the .otf and .tff files from /Users/MyUserName/Library/Fonts (if I'm on a Mac -- would be even better to have a solution that's not Mac-specific) to /usr/share/fonts?

Related

Add file to Docker Image

I am new to docker, and I have created a docker image for sparq spatial reasoning toolbox using pull docker pull dwolter/sparq:latest, (Gethub: https://github.com/dwolter/SparQ).
The sparq catains set of calculus in form of lisp files, which can be used to do spatial reasoning, using the Sparq docker image in the windows docker.
The thing that I have developed my own calculi and I need to add it to the image.
I have tried to do that using the cp command but I could not. Because I don't know the path of the file indside the image, in otherwords, where I should place the file inside the image, also when place it in the main root of a container, and applied the command commit, it generated error: access denied by ther resource.
first question is :
Does the path in the image has the same path in the sparq application folder which I have already downloaded?
Also, How I can add this culculi (lisp file) to the image in docker ?
P.s. I have also downloaded the folder which contains the application (sparq and all its files and folders) and I have placed my calculi inside the appropriate folder ( caculi folder and it works fine).
I run it using Linux command line and it works fine, Now I need to use this application through the docker.
As I have the application on folder.
Can I create an image on my own based on the folder that contains the application ?
The Sparq Dockerfile indicates the working directory is set to /root/sparq. That means, you should be able to run the following copy command in your own Dockerfile to place your lisp file in the same place you have locally, the place where all other Calculi lisp files are located:
FROM dwolter/sparq
COPY ./path/to/my/Calculi/file.lisp ./Calculi
Then run docker build . to build a Docker image containing sparq and your file. Then, it should be ready to run.
NOTE: I am not familiar with lisp. If it needs to be compiled, the compile command will need to be added to the Dockerfile after the COPY.

Docker multistage copy path list from files

I have a base image (mybase:1.0.0) which builds and installs a few CMake projects successfully.
I want to make a more specialised image (myapp:1.0.0) which is composed from mybase:1.0.0 and adds my application, which depends on the libraries and binaries installed in mybase:1.0.0.
Each CMake build creates install_manifest.txt which has a path to where each binary or library was installed>
Example manifest:
/usr/local/bin/myapp
/usr/local/lib/mylib.so
In my specialised image I would like to copy these paths to my new container, which should be based not on mybase:1.0.0 but another specialised (and compatible) image (in my case nvidia/cuda:10.2-base-ubuntu18.04).
To do so I would have my dockerfile something like:
FROM nvidia/cuda:10.2-base-ubuntu18.04
COPY --from mybase:1.0.0 /usr/local/bin/myapp /usr/local/bin/myapp
COPY --from mybase:1.0.0 /usr/local/lib/mylib.so /usr/local/lib/mylib.so
My problem is that there are many (~200) files which need to be installed, and including them all in the dockerfile would be very ugly, and when the libraries update and the base image is built again, the dockerfile would need to be updated.
One solution would be to copy all the files from the build directory directly to /usr/local/bin and /usr/local/lib. But in order to reduce file size significantly, the build directories are removed (aside from the manifests) after the base image has installed them (which is a requirement).
A workaround to this would be to have a second 'pre-base' image which deletes the installed images after build (the build libraries have interdependencies which require them to be installed).
Is there a way to do a COPY --from where the contents of a manifest.txt specify the SRC paths?
Or any practices which do similar that I can use?
I asked for a feature request to do so, and I received a response on how to do it using the docker experimental API.
See: https://github.com/docker/for-linux/issues/1060#issuecomment-655566235

Installing Hyperledger fabric dependent binaries using Docker for Mac

I downloaded Docker for Mac since it was a prerequisite for Hyperledger Fabric (also listed here).
Now, I downloaded platform specific binaries listed here.
The instructions said:
If you are using Docker for Mac, you will need
to use a location under /Users, /Volumes, /private, or /tmp. To use a
different location, please consult the Docker documentation for file
sharing.
So,I used the following directory: /Users/user_name/Documents/Hyperledger\ Fabric/
I followed the same commands as listed on the site.
However, I was not able to add the line below to the ~/.bash_profile.
export PATH=/Users/user_name/Documents/Hyperledger\ Fabric/bin:$PATH
If I added the above line and ran the bash_profile, it gave an error and after that commands like ls, open were giving error not found.
It seems that there is a problem with the file location since I
installed Docker for Mac instead of Docker toolbox.
The problem is that your directory name contains a space. One way to avoid this problem is to specify a directory name that has no spaces. This would be the ideal approach since once you introduce a space in the PATH variable it would need to be quoted where used subsequently.
Alternately, you could set the path as:
export PATH="/Users/user_name/Documents/Hyperledger Fabric/bin":$PATH
However, as noted this has drawbacks.

How do I determine if an application is built by Electron or not?

How do I determine if an application is built by Electron or not?
Could I always find specific file or binary on Electron apps?
Please give me some advice, thanks.
There are a few "non-futureproof" ways to check if an app was built on Electron and they vary depending of the OS.
You will need to go in your application folder (for example Applications for macOS, Program Files for Windows or /usr/share for Linux...
Here are some examples of the files/directory you may find in your application folder:
 Linux / Win32
These two OS have basically the same structure, so it's pretty easy to check what you want
locales/
resources/
blink_image_resources_200_percent.pak
chrome_100_percent.pak
chrome_200_percent.pak
content_resources_200_percent.pak
content_shell.pak
icudtl.dat
vkswiftshader.dll
vkswiftshader_icd.json
There are also some files like
libffmpeg.so / ffmpeg.dll
libnode.so / node.dll
depending of the OS you're on.
 macOS
It's a bit more complicated here. You might need to check the Info.plist file to see if there is any reference to Electron.
As unseen_damage said, you can also check in [app folder]/Contents/Resources if there is an app.asar as .asar files are specifically created for Electron.
Anyway, all those files may see their names changes someday, so don't consider them as a reliable way to check if "any" app is built on Electron, it's more of a manual way to check it.
MacOs
To find all Electron apps by finding the .asar file on your mac, use this.
open Terminal
run this command
find /Applications -name '*.asar' -print
MAC:
open a terminal type cd /Applications, then, change directory (cd) into the name of the application you want to check. For example, if it is iTunes, you would do the following /Applications/iTunes.app/Contents/Resources. If you see an app.asar file, or something similar with the .asar suffix, it is most likely an Electron App.
Windows:
Open up the program files directory of the application you are wondering about, and check the file folder for any file with .asar suffix. This can be done via the search, terminal, etc.
Bottom line- Electron apps, when packaged, are bundled into an asar file, and you can search for this file extension to see if the program was built with electron.
Documentation- http://electron.atom.io/docs/tutorial/application-packaging/
macOS
You can also run the following terminal command:
find /Applications -name "*Electron Framework*" | cut -d/ -f3 | sort -u | cut -d. -f1
This will output an alphabetized and cleaned up list of just the application names.
Source: https://talk.macpowerusers.com/t/why-the-dislike-of-electron-apps/20697/20

The command to add to path in Julia language

How can I add a path to my current path in Julia, so that I can organize files and modules in folders, but still access them?
Note: the following paths may be Unix-specific.
You can add the file .juliarc.jl to your home directory, and include the line
#everywhere push!(LOAD_PATH,"/path/to/my/code")
The #everywhere ensures that it will work even if you've started julia with multiple workers.
This is an updated and extended version of the answer by tholy and ederag. On Linux and Windows with Julia 1.0 one can add the folder myproject/src in the user homefolder to the Julia LOAD_PATH by adding
using Distributed
#everywhere push!(LOAD_PATH, joinpath(homedir(), "myproject", "src"))
to <homedir>/julia/config/startup.jl. For a fresh Julia install, startup.jl nor the folder config exists (on Linux at least). Just create the file and folder and Julia will read startup.jl automatically.

Resources