-
Notifications
You must be signed in to change notification settings - Fork 0
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
46e1d0f
commit 64c905d
Showing
4 changed files
with
91 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM python:3.9-slim-buster | ||
LABEL maintainer="Darius Stefan <[email protected]>" | ||
|
||
RUN apt-get -y update -qq && \ | ||
apt-get -y install git | ||
|
||
RUN git clone https://github.com/OpenSIPS/python-opensips.git /usr/src/python-opensips && \ | ||
cd /usr/src/python-opensips && \ | ||
python3 setup.py install &&\ | ||
cd / && rm -rf /usr/src/python-opensips | ||
|
||
RUN apt-get purge -y git && \ | ||
apt-get autoremove -y && \ | ||
apt-get clean | ||
|
||
ADD "run.sh" "/run.sh" | ||
|
||
ENV PYTHONPATH=/usr/lib/python3/dist-packages | ||
|
||
ENTRYPOINT [ "/run.sh" ] |
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,10 @@ | ||
NAME ?= pyhton-opensips | ||
OPENSIPS_DOCKER_TAG ?= latest | ||
|
||
all: build | ||
|
||
.PHONY: build | ||
build: | ||
docker build \ | ||
--tag="opensips/pyhton-opensips:$(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,47 @@ | ||
# OpenSIPS Python Docker Image | ||
|
||
Docker recipe for running a container with pre-installed OpenSIPS Python packages. | ||
|
||
## Building the image | ||
You can build the docker image by running: | ||
``` | ||
make build | ||
``` | ||
|
||
This command will build a docker image with OpenSIPS Python packages installed, along with | ||
`opensips-mi` and `opensips-event` command line tools. | ||
|
||
## Parameters | ||
|
||
The container receives parameters in the following format: | ||
``` | ||
CMD [PARAMS]* | ||
``` | ||
|
||
Meaning of the parameters is as it follows: | ||
* `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-mi` 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 --rm opensips/python-opensips:latest script.sh | ||
``` | ||
|
||
Similarly, run a python script: | ||
``` | ||
docker run --rm opensips/python-opensips:latest script.py | ||
``` | ||
|
||
To run a single MI command, use: | ||
``` | ||
docker run --rm opensips/python-opensips:latest -t datagram uptime | ||
``` | ||
|
||
## DockerHub | ||
|
||
Docker images are available on | ||
[DockerHub](https://hub.docker.com/r/opensips/python-opensips). |
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,14 @@ | ||
#!/bin/bash | ||
|
||
CMD=$1 | ||
shift | ||
|
||
if [[ CMD == *.py ]]; then | ||
TOOL=python3 | ||
elif [[ CMD == *.sh ]]; then | ||
TOOL=bash | ||
else | ||
TOOL=opensips-mi | ||
fi | ||
|
||
exec $TOOL $CMD "$@" |