Skip to content

sample application touring API, tests, continuous integration, continuous deployments, image publishing and so on

License

Notifications You must be signed in to change notification settings

sombriks/simple-knex-koa-example

Repository files navigation

tests Docker Image Version (latest semver)

sample application for this blog post and for this one too

This is a project template

If starting a backend node project with koa, consider either use this template directly or just grab some inspiration.

Requirements

  • node 18

If you plan to run in production mode

  • postgresql

If you plan to create a docker image container

  • docker

See the infrastructure folder for further details.

If you plan to deploy the image into a kubernetes cluster, there are several options, but try to set up kind, since you already had to setup docker.

How to run this application

There are several ways to run this app:

Bare metal

Install node dependencies and run the project:

npm install
npm run dev

Docker

Create an image:

docker build -f infrastructure/Dockerfile \
  -t sombriks/simple-knex-koa-example:development .

Then spin up a container:

docker run -it \
  -e NODE_ENV=development \
  -e PORT=3000 \
  -p 3000:3000 sombriks/simple-knex-koa-example:development

Docker compose

Create the image as shown in the previous section, then spin up the provided docker compose example file:

NODE_ENV=development docker compose -f infrastructure/docker-compose.yml up

In all examples above, the app will start in development mode.

Kubernetes

See the details here.

The articles

As mentioned in the beginning of this document, this source code was used to offer support for a blog post. Eventually other articles came.

Knex will help you to build your queries and that's it, no ORM, M-N relations, nothing. it does only one thing and does it well.

At some point container images became the de-facto standard for application publishing and there is no way back from there.

but this is not a bad thing, once you figure out that good practices still mostly the same.

Kubernetes is how people put things in production nowadays and sometimes it can be tricky to test because it's heavy.

By using kind as kubernetes runtime, part of this issue is solved and the developer can be more confident on how the application will behave inside the belly of the beast.

GitHub Actions can be a very handy too to implement continuous Integration, Continuous Delivery and Continuous Deployment.

I built some simple, useless yet educational examples so when building more complex workflows this material could be consulted.

It was key to build this good enough example of deployment workflow base for GitOps pull based solutions combined with ArgoCD.

References