Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] Add curl or wget to containers for Docker healthchecks #989

Open
binaryfire opened this issue Oct 6, 2023 · 1 comment
Open

Comments

@binaryfire
Copy link

binaryfire commented Oct 6, 2023

Hi

Could you add curl or wget to the container images? That will let us use Docker's native healthchecks to ping the service and check for Ok. Which will allow Soketi's health to be monitored by monitoring software.

I noticed that wget is in the Debian Dockerfile but it's not available inside the quay.io Debian images for some reason. Not sure why.

@msigwart
Copy link

Came across the same issue for the distroless images and solved it by creating a modified Docker image with a built-in node-based health check for Soketi:

  1. Create a health check script for Node.
// healthcheck.js
#!/usr/bin/env node

const http = require('node:http');

const options = {
    hostname: 'localhost',
    port: process.env.SOKETI_PORT || 6001,
    path: '/',
    method: 'GET'
};

http.request(options, res => {
    let body = '';

    res.on('data', chunk => {
        body += chunk;
    });

    res.on('end', () => {
        if (body === 'OK') {
            process.stdout.write('We are healthy!');
            process.exit(0);
        } else {
            process.stdout.write('Uh oh, we are not healthy!');
            process.exit(1);
        }
    });
})
    .on('error', () => {
        process.stdout.write('Uh oh, we are not healthy!');
        process.exit(1);
    })
    .end();
  1. Create a Dockerfile based off the distroless Soketi image:
# Dockerfile
FROM quay.io/soketi/soketi:1.6-16-distroless
COPY docker/healthcheck.js /app/
  1. Build the Docker image:
docker build -t soketi-with-healthcheck .
  1. After building and running the Docker image, you can perform the healthcheck by running:
docker exec -i -t soketi-with-healthcheck /nodejs/bin/node healthcheck.js

Or if you're deploying the Docker container in AWS ECS for example, define the healthcheck in your container task definition like this:

          HealthCheck:
            Command: [ "CMD", "/nodejs/bin/node", "healthcheck.js" ]
            Interval: 5
            Retries: 3
            Timeout: 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants