-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a0e40f
commit 3171f51
Showing
7 changed files
with
179 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
name: Trigger OpenSIPS CLI Images build and publish | ||
name: Push OpenSIPS CLI Images in Docker Hub | ||
|
||
on: | ||
push: | ||
repository_dispatch: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Repository Dispatch | ||
uses: myrotvorets/[email protected] | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/[email protected] | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
token: ${{ secrets.DOCKER_OPENSIPS_CLI_PAT }} | ||
repo: OpenSIPS/docker-opensips-cli | ||
type: OpenSIPS CLI Trigger | ||
context: ./docker/ | ||
push: true | ||
tags: opensips/opensips-cli:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
name: Update Docker Hub Description | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- ./docker/docker.md | ||
- .github/workflows/docker-readme.yml | ||
|
||
jobs: | ||
dockerHubDescription: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
|
||
- name: Docker Hub Description | ||
uses: peter-evans/dockerhub-description@v4 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
repository: opensips/opensips-cli | ||
readme-filepath: ./docker/docker.md | ||
short-description: ${{ github.event.repository.description }} | ||
enable-url-completion: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM python:3.9-slim-buster | ||
LABEL maintainer="Razvan Crainea <[email protected]>" | ||
|
||
USER root | ||
|
||
# Set Environment Variables | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
#install basic components | ||
RUN apt-get -y update -qq && \ | ||
apt-get -y install git default-libmysqlclient-dev gcc | ||
|
||
#add keyserver, repository | ||
RUN git clone https://github.com/OpenSIPS/opensips-cli.git /usr/src/opensips-cli && \ | ||
cd /usr/src/opensips-cli && \ | ||
python3 setup.py install clean --all && \ | ||
cd / && rm -rf /usr/src/opensips-cli | ||
|
||
RUN apt-get purge -y git gcc && \ | ||
apt-get autoremove -y && \ | ||
apt-get clean | ||
|
||
ADD "run.sh" "/run.sh" | ||
|
||
ENV PYTHONPATH /usr/lib/python3/dist-packages | ||
|
||
ENTRYPOINT ["/run.sh", "-o", "communication_type=http"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
NAME ?= opensips-cli | ||
OPENSIPS_DOCKER_TAG ?= latest | ||
|
||
all: build start | ||
|
||
.PHONY: build start | ||
build: | ||
docker build \ | ||
--tag="opensips/opensips-cli:$(OPENSIPS_DOCKER_TAG)" \ | ||
. | ||
|
||
start: | ||
docker run -d --name $(NAME) opensips/opensips-cli:$(OPENSIPS_DOCKER_TAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# OpenSIPS CLI Docker Image | ||
|
||
Docker recipe for running [OpenSIPS Command Line | ||
Interface](https://github.com/OpenSIPS/opensips-cli). | ||
|
||
## Building the image | ||
You can build the docker image by running: | ||
``` | ||
make build | ||
``` | ||
|
||
This command will build a docker image with OpenSIPS CLI master version taken from | ||
the git repository | ||
|
||
## Parameters | ||
|
||
The container receives parameters in the following format: | ||
``` | ||
[-o KEY=VALUE]* CMD [PARAMS]* | ||
``` | ||
|
||
Meaning of the parameters is as it follows: | ||
|
||
* `-o KEY=VALUE` - used to tune `opensips-cli` at runtime; these parameters | ||
will end up in opensips-cli config file, in the `default` section, as | ||
`KEY: VALUE` lines | ||
* `CMD` - the command used to run; if the `CMD` ends with `.sh` extension, it | ||
will be run as a bash script, if the `CMD` ends with `.py` extension, it is | ||
run as a python script, otherwise it is run as a `opensips-cli` command | ||
* `PARAMS` - optional additional parameters passed to `CMD` | ||
|
||
## Run | ||
|
||
To run a bash script, simply pass the connector followed by the bash script: | ||
``` | ||
docker run -d --name opensips-cli opensips/opensips-cli:latest \ | ||
-o url=http://8.8.8.8:8888/mi script.sh | ||
``` | ||
|
||
Similarly, run a python script: | ||
``` | ||
docker run -d --name opensips-cli opensips/opensips-cli:latest \ | ||
-o url=http://8.8.8.8:8888/mi script.py | ||
``` | ||
|
||
To run a single MI command, use: | ||
``` | ||
docker run -d --name opensips-cli opensips/opensips-cli:latest \ | ||
-o url=http://8.8.8.8:8888/mi -x mi ps | ||
``` | ||
|
||
## DockerHub | ||
|
||
Docker images are available on | ||
[DockerHub](https://hub.docker.com/r/opensips/opensips-cli). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
OPTS= | ||
CMD= | ||
PARAMS= | ||
CFG=/etc/opensips-cli.cfg | ||
|
||
echo "[default]" > "$CFG" | ||
|
||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
-o|--option) | ||
shift | ||
P=$(cut -d'=' -f1 <<<"$1") | ||
V=$(cut -d'=' -f2- <<<"$1") | ||
echo "$P: $V" >> "$CFG" | ||
;; | ||
*) | ||
if [ -z "$CMD" ]; then | ||
CMD="$1" | ||
else | ||
PARAMS="${PARAMS} ${1}" | ||
fi | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
if [[ $CMD == *.py ]]; then | ||
TOOL=python3 | ||
elif [[ $CMD == *.sh ]]; then | ||
TOOL=bash | ||
else | ||
TOOL=opensips-cli | ||
fi | ||
|
||
exec $TOOL $CMD $PARAMS |