A small NodeJS service providing a UNIX socket for communication. Easily trigger a rebuild from within your Dokku apps.
This repository has been archived on 2026-06-11. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • JavaScript 75.5%
  • Shell 24.5%
Find a file
2021-02-22 15:08:54 +01:00
dist chore: initial commit 2021-02-22 15:08:30 +01:00
src chore: initial commit 2021-02-22 15:08:30 +01:00
.editorconfig chore: initial commit 2021-02-22 15:08:30 +01:00
.gitignore chore: initial commit 2021-02-22 15:08:30 +01:00
.prettierrc chore: initial commit 2021-02-22 15:08:30 +01:00
CHANGELOG.md chore(release): 0.1.0 2021-02-22 15:08:54 +01:00
install.sh chore: initial commit 2021-02-22 15:08:30 +01:00
LICENSE chore: initial commit 2021-02-22 15:08:30 +01:00
package.json chore: initial commit 2021-02-22 15:08:30 +01:00
README.md chore: initial commit 2021-02-22 15:08:30 +01:00
remove.sh chore: initial commit 2021-02-22 15:08:30 +01:00
tsconfig.json chore: initial commit 2021-02-22 15:08:30 +01:00
yarn.lock chore: initial commit 2021-02-22 15:08:30 +01:00

dokku-rebuild

A small NodeJS service providing a unix socket for communication. When a rebuild is triggered the service will execute the dokku ps:rebuild <your app> command to rebuild your app.

Requirements

  • NodeJS (tested on v14, older versions will likely work too)

Install Service

Configuration

Edit the APP_NAME variable in the dist/dokku-rebuild.service file to match your app name.

Environment=APP_NAME=<your app>

Run install script

$ sudo ./install.sh

Remove Service

$ sudo ./remove.sh

Usage

The service will provide a unix socket at /var/run/dokku-rebuild/dokku-rebuild.sock for other processes to access.

Mount socket location

To make the socket available in your app you need to mount it to the docker container of your app. Dokku makes this quite easy.

$ dokku storage:mount <your app> /var/run/dokku-rebuild:/var/run/dokku-rebuild

You might need to restart your app for this change to take affect.

$ dokku ps:restart <your app>

Connect to the socket

Find out how to use unix sockets in your language. This is a NodeJS example.

const net = require('net');

const socketPath = '/var/run/dokku-rebuild/dokku-rebuild.sock';
const client = net.createConnection(socketPath);

// Write 'rebuild' to the socket to trigger a new rebuild
client.on('connect', () => {
  client.write('rebuild');
});

// Listen for current stage
client.on('data', (data) => {
  const stage = data.toString();
  console.log('currentStage:', stage);
});

// When the connection is closed the build is over
client.on('close', () => {
  console.log('done');
});

Setup stage feedback

The service will scan each line of the build output for instructions. To tell the service a new stage has been reached, echo [dokku-rebuild] <your stage> to the output. Stage names may only contain letters, numbers, dashes and underscores.

Example with Docker:

...

# Install dependencies
RUN echo "[dokku-rebuild] setup"
COPY package.json ./
COPY yarn.lock ./
RUN yarn

# Build with TypeScript
RUN echo "[dokku-rebuild] build"
COPY . .
RUN yarn build

...

Similar projects

This project was heavily inspired by dokku-daemon. If you want more than just trigger a rebuild, you can checkout that project instead.