Skip to content

Instantly share code, notes, and snippets.

@apetersson
Last active September 2, 2023 09:59
Show Gist options
  • Save apetersson/5f7b91dfb053f20ba0816a6cd576b291 to your computer and use it in GitHub Desktop.
Save apetersson/5f7b91dfb053f20ba0816a6cd576b291 to your computer and use it in GitHub Desktop.

Dockerfile for signal-cli

Creating a Dockerfile for signal-cli provides an isolated environment where you can run the tool without polluting your main system with its dependencies. Here's a basic Dockerfile for this purpose:

# Use an official Java base image. Since signal-cli requires at least JRE 17, we'll use that.
FROM openjdk:17-slim

# Set the version of signal-cli you want to install
ENV SIGNAL_CLI_VERSION=x.y.z

# Download and install signal-cli
RUN apt-get update && \
    apt-get install -y wget && \
    wget https://github.com/AsamK/signal-cli/releases/download/v"${SIGNAL_CLI_VERSION}"/signal-cli-"${SIGNAL_CLI_VERSION}"-Linux.tar.gz && \
    tar xf signal-cli-"${SIGNAL_CLI_VERSION}"-Linux.tar.gz -C /opt && \
    ln -sf /opt/signal-cli-"${SIGNAL_CLI_VERSION}"/bin/signal-cli /usr/local/bin/

# Set the entrypoint to signal-cli
ENTRYPOINT ["signal-cli"]

# By default, show the help menu. Users can override this to send/receive messages etc.
CMD ["--help"]

Building and Using the Docker Image

  1. Replace x.y.z in the Dockerfile with the latest version of signal-cli that you want to use.
  2. Save the Dockerfile to a directory.
  3. Build the Docker image:
docker build -t signal-cli:latest .
  1. Once built, you can run signal-cli using Docker:
docker run --rm signal-cli:latest

If you want to send or receive messages, override the default command:

docker run --rm signal-cli:latest -a +1234567890 send -m "Hello" +0987654321

Note: If you intend to use this regularly, you might want to consider mounting a volume to persist signal-cli data, especially since cryptographic keys and other data are stored in user's home directory inside the container.

Note 2: This is just a draft code, completely untested, if you find any errors, let me know.

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