Skip to content

Commit 64c905d

Browse files
committed
add docker image
1 parent 46e1d0f commit 64c905d

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed

docker/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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" ]

docker/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
.

docker/docker.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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).

docker/run.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 "$@"

0 commit comments

Comments
 (0)