0

I have a small NodeJS app I want to deploy to IBM Cloud as an "action". What I've been doing until now is just zipping the project files and creating/updating actions using the IBM Cloud CLI like this:

ibmcloud fn action create project-name C:\Users\myuser\Desktop\node-js-projects\some-project\test-folder.zip --kind nodejs:12

This was working great, however I'm now testing a new project which has a much larger modules folder, and as such IBMCloud won't accept it. I've turned my attention to using Docker as the below article explains.

https://medium.com/weekly-webtips/adding-extra-npm-modules-to-ibm-cloud-functions-with-docker-fabacd5d52f1

Everything makes sense, however I have no idea what to do with the credentials that the app uses. Since IBM Cloud seems to require you to run "docker push" I'm assuming it's not safe to include a .env file in the docker image?

I know in IBM Cloud I can pass "parameters" to an action but not sure if that helps here. Can those params be accessed from a piece of code deployed this way?

Would really appreciate some help on this one. Hoping there's a straightforward standard way of doing it that I've just missed. I'm brand new to docker so still learning.

KarlB25
  • 83
  • 6
  • You can pass parameters to an action, but also BIND parameters, credentials or services. The function has access to its environment from where you could obtain an API key to unlock a secrets manager. Many options. – data_henrik Sep 19 '21 at 17:19
  • Maybe I'm a little confused on the purpose of the docker image. I've seen examples where application code is included in the image, but also examples of people saying that the image is ONLY for defining the environment and that all code should be passed to it. The idea being that you don't keep recreating images when the app code updates. This makes sense. It would also mean that I could pass the .zip file with the .js files to the action in IBM Cloud alongside the docker image. It wouldn't matter that the modules file is too big since they would be in the image. Hope I'm on the right track. – KarlB25 Sep 19 '21 at 18:43
  • OpenWhisk / IBM Cloud Functions uses Docker containers for running actions. Thus, you either pass code to be run to a Node.js / Python / ... container or you provide the entire container to be run. That is independent of how to pass or use credentials. – data_henrik Sep 20 '21 at 06:50

0 Answers0