Skip to content

epiresdasilva/psql-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

psql-function

Native serverless function with PostgreSQL.

The idea behind this function is to prove a concept about creating serverless functions quickly no matter your programming language.

In that example, we are using bash script and psql to create a serverless function that gets an account in the database.

Prerequisites

Setup

  • Create the database structure contained in the schema.sql file in your PostgreSQL instance.
  • Configure the exec file with your credentials to the PostgreSQL instance
HOSTNAME=""
PORT=""
USERNAME=""
PASSWORD=""
PGPASSWORD=""
PGSSLROOTCERT=""

Creating your function

Build your Docker image:

docker build -t epiresdasilva/psql-function .

Tag the docker image:

docker tag epiresdasilva/psql-function epiresdasilva/psql-function:0.0.1

Push the docker image to the Docker hub:

docker push epiresdasilva/psql-function:0.0.1

Create the function in the IBM Cloud:

ibmcloud fn action create psql-function --docker epiresdasilva/psql-function:0.0.1

PS: Replace epiresdasilva with your username in the docker hub

Running

You must pass as payload the branch and account number, exactly like that:

{"branch": 1, "number": 1}

You'll get a response like that:

About

Native serverless function with PostgreSQL

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published