openfaas / templates

OpenFaaS Classic templates
https://www.openfaas.com
MIT License
279 stars 227 forks source link

Support adding apk repositories #169

Open maiermic opened 5 years ago

maiermic commented 5 years ago

Thanks to #28 it is possible to install additional packages using --build-arg ADDITIONAL_PACKAGE=<package-names>. However, you can only install packages from the default repositories defined in /etc/apk/repositories.

Possible Solution

Add another build argument ADDITIONAL_REPOSITORY, whose content is appended to /etc/apk/repositories and update the package list. This might be accomplished by modifying an existing installation statement in the Dockerfile

RUN apk --no-cache add ca-certificates ${ADDITIONAL_PACKAGE}

to

ARG ADDITIONAL_REPOSITORY
RUN printf ${ADDITIONAL_REPOSITORY} >> /etc/apk/repositories && \
  apk --update --no-cache add ca-certificates ${ADDITIONAL_PACKAGE}

Thereby, you can build it using two additional repositories

faas-cli build \
  --build-arg ADDITIONAL_REPOSITORY="http://dl-cdn.alpinelinux.org/alpine/edge/main\nhttp://dl-cdn.alpinelinux.org/alpine/edge/community" \
  --build-arg ADDITIONAL_PACKAGE=<package-name> \
  -f <yml>