Skip to content

Instantly share code, notes, and snippets.

@pyramation
Created April 5, 2019 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pyramation/ae741b0ea37c9bbeb6387d7a21c07f31 to your computer and use it in GitHub Desktop.
Save pyramation/ae741b0ea37c9bbeb6387d7a21c07f31 to your computer and use it in GitHub Desktop.
npm private modules on openfaas
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
#!/bin/bash
if [ -z "$1" ]
then
echo "Usage: $(basename $0) <fn>"
exit 1
fi
test -n "${NPM_TOKEN}" || (echo you need an NPM_TOKEN!; exit 1)
faas build -f stack.yml --build-arg NPM_TOKEN=${NPM_TOKEN} --filter=$1
faas deploy -f stack.yml --gateway 127.0.0.1:31112 --filter=$1
#!/bin/bash
if [ -z "$1" ]
then
echo "Usage: $(basename $0) <fn>"
exit 1
fi
test -n "${NPM_TOKEN}" || (echo you need an NPM_TOKEN!; exit 1)
faas build -f stack-prod.yml --build-arg NPM_TOKEN=${NPM_TOKEN} --filter=$1
docker push docker.mycompany.io/mycompany/$1
faas deploy -f stack-prod.yml --gateway https://gateway.mycompany.io --filter=$1
FROM mhart/alpine-node:10.11.0
RUN apk --no-cache add curl \
&& echo "Pulling watchdog binary from Github." \
&& curl -sSLf https://github.com/openfaas-incubator/of-watchdog/releases/download/0.4.1/of-watchdog > /usr/bin/fwatchdog \
&& chmod +x /usr/bin/fwatchdog \
&& apk del curl --no-cache
RUN addgroup -S app && adduser -S -g app app
RUN mkdir -p /home/app
RUN chown app:app /home/app
WORKDIR /home/app
RUN mkdir -p /usr/lib/node_modules && chown -R app:app /usr/lib/node_modules
RUN chown -R app:app /usr/bin
USER app
ARG NPM_TOKEN
COPY .npmrc .npmrc
ENV NODE_ENV production
ENV NPM_CONFIG_LOGLEVEL warn
RUN npm install -g @mycompany/my-private-module-cli@0.0.48
RUN rm .npmrc
ENV cgi_headers="true"
ENV fprocess="my-private-module"
ENV mode="http"
ENV PORT 9999
ENV upstream_url="http://127.0.0.1:9999"
ENV exec_timeout="20s"
ENV write_timeout="25s"
ENV read_timeout="25s"
HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1
CMD ["fwatchdog"]
provider:
name: faas
gateway: https://gateway.mycompany.io
functions:
my-private-function:
lang: dockerfile
handler: ./my-private-function
image: docker.mycompany.io/mycompany/my-private-function:latest
environment:
scale_from_zero: true
inactivity_duration: 1m
secrets:
- redis-config
provider:
name: faas
gateway: http://127.0.0.1:8080
functions:
my-private-module:
lang: dockerfile
handler: ./my-private-module
image: mycompany/my-private-module:latest
environment:
scale_from_zero: true
inactivity_duration: 1m
secrets:
- dockerhub
- redis-config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment