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

How to add fonts to this image? #18

Open
atrudeau-vitall opened this issue Feb 6, 2023 · 5 comments
Open

How to add fonts to this image? #18

atrudeau-vitall opened this issue Feb 6, 2023 · 5 comments

Comments

@atrudeau-vitall
Copy link

I saw this comment about adding new fonts to the base docker image, and I was wondering how I'd go about that? The font I need doesn't seem to be on https://pkgs.org/.

For reference, I'd like to add this font. Any help is appreciated!

@shiv4623
Copy link

Hi, do you know the full implementation process on how to build image and push image to the ECR?

@samuelantonioli
Copy link

samuelantonioli commented Apr 5, 2023

Hey,
I found a solution. Put your ttf files into a fonts/ directory in your repository and use the following Dockerfile:

Dockerfile

FROM public.ecr.aws/shelf/lambda-libreoffice-base:7.4-node16-x86_64
COPY ./ ${LAMBDA_TASK_ROOT}/
COPY ./fonts ${HOME}/.fonts
# dependency not supplied by lambda-libreoffice-base image
# https://github.com/shelfio/aws-lambda-libreoffice/issues/211
RUN fc-cache && yum install java-1.8.0-openjdk-devel -y
RUN npm install
CMD [ "app.handler" ]

What it does is it puts the fonts into the $HOME folder and installs them using fc-cache.

package.json

{
  "dependencies": {
    "@shelf/aws-lambda-libreoffice": "^5.0.0"
  }
}

serverless.yml

service: pdfgen-lambda
frameworkVersion: '3'
provider:
  name: aws
  ecr:    
    images:
      appimage:
        path: ./
functions:
  libreoffice:
    url: true
    image:
      name: appimage

And then

sls deploy
sls invoke --function libreoffice

@adussarps
Copy link

Thanks for the help !

@adussarps
Copy link

In the end it does not work with otf fonts. Would someone have a solution for it?

@adussarps
Copy link

In the end it does not work with otf fonts. Would someone have a solution for it?

Ok, the same approach worked but targeting another directory !

FROM --platform=linux/amd64 public.ecr.aws/shelf/lambda-libreoffice-base:7.4-node16-x86_64

COPY ./ ${LAMBDA_TASK_ROOT}/

RUN mkdir -p /usr/share/fonts/opentype

COPY ./fonts/marinanne  /usr/share/fonts/opentype

# dependency not supplied by lambda-libreoffice-base image
RUN fc-cache -f -v
RUN yum install java-1.8.0-openjdk-devel -y
RUN npm install --only=production

CMD [ "handler.handler" ]

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

No branches or pull requests

4 participants