File tree Expand file tree Collapse file tree 4 files changed +91
-0
lines changed
Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM python:3.9-slim-buster
2+ LABEL maintainer="Darius Stefan <darius.stefan@opensips.org>"
3+
4+ RUN apt-get -y update -qq && \
5+ apt-get -y install git
6+
7+ RUN git clone https://github.com/OpenSIPS/python-opensips.git /usr/src/python-opensips && \
8+ cd /usr/src/python-opensips && \
9+ python3 setup.py install &&\
10+ cd / && rm -rf /usr/src/python-opensips
11+
12+ RUN apt-get purge -y git && \
13+ apt-get autoremove -y && \
14+ apt-get clean
15+
16+ ADD "run.sh" "/run.sh"
17+
18+ ENV PYTHONPATH=/usr/lib/python3/dist-packages
19+
20+ ENTRYPOINT [ "/run.sh" ]
Original file line number Diff line number Diff line change 1+ NAME ?= pyhton-opensips
2+ OPENSIPS_DOCKER_TAG ?= latest
3+
4+ all : build
5+
6+ .PHONY : build
7+ build :
8+ docker build \
9+ --tag=" opensips/pyhton-opensips:$( OPENSIPS_DOCKER_TAG) " \
10+ .
Original file line number Diff line number Diff line change 1+ # OpenSIPS Python Docker Image
2+
3+ Docker recipe for running a container with pre-installed OpenSIPS Python packages.
4+
5+ ## Building the image
6+ You can build the docker image by running:
7+ ```
8+ make build
9+ ```
10+
11+ This command will build a docker image with OpenSIPS Python packages installed, along with
12+ ` opensips-mi ` and ` opensips-event ` command line tools.
13+
14+ ## Parameters
15+
16+ The container receives parameters in the following format:
17+ ```
18+ CMD [PARAMS]*
19+ ```
20+
21+ Meaning of the parameters is as it follows:
22+ * ` CMD ` - the command used to run; if the ` CMD ` ends with ` .sh ` extension, it
23+ will be run as a bash script, if the ` CMD ` ends with ` .py ` extension, it is
24+ run as a python script, otherwise it is run as a ` opensips-mi ` command
25+ * ` PARAMS ` - optional additional parameters passed to ` CMD `
26+
27+ ## Run
28+
29+ To run a bash script, simply pass the connector followed by the bash script:
30+ ```
31+ docker run --rm opensips/python-opensips:latest script.sh
32+ ```
33+
34+ Similarly, run a python script:
35+ ```
36+ docker run --rm opensips/python-opensips:latest script.py
37+ ```
38+
39+ To run a single MI command, use:
40+ ```
41+ docker run --rm opensips/python-opensips:latest -t datagram uptime
42+ ```
43+
44+ ## DockerHub
45+
46+ Docker images are available on
47+ [ DockerHub] ( https://hub.docker.com/r/opensips/python-opensips ) .
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ CMD=$1
4+ shift
5+
6+ if [[ CMD == * .py ]]; then
7+ TOOL=python3
8+ elif [[ CMD == * .sh ]]; then
9+ TOOL=bash
10+ else
11+ TOOL=opensips-mi
12+ fi
13+
14+ exec $TOOL $CMD " $@ "
You can’t perform that action at this time.
0 commit comments