Last active
April 5, 2019 19:37
-
-
Save pyramation/65c64592b2c3e236dd27ad3c87c88987 to your computer and use it in GitHub Desktop.
npm private modules on openfaas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//registry.npmjs.org/:_authToken=${NPM_TOKEN} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider: | |
name: faas | |
gateway: https://gateway.mycompany.io | |
functions: | |
my-private-function: | |
lang: dockerfile | |
handler: ./my-private-module | |
image: docker.mycompany.io/mycompany/my-private-module:latest | |
environment: | |
scale_from_zero: true | |
inactivity_duration: 1m | |
secrets: | |
- redis-config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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