-
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.
Merge pull request #3 from OpenSIPS/dockerimage
Add Docker image
- Loading branch information
Showing
7 changed files
with
148 additions
and
1 deletion.
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,39 @@ | ||
name: Push OpenSIPS Python Images to Docker Hub | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v2.1.0 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
|
||
- name: Get latest tag if manually triggered | ||
id: get_tag | ||
run: | | ||
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | ||
git fetch --tags | ||
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) | ||
echo "tag=$LATEST_TAG" >> $GITHUB_ENV | ||
else | ||
echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV | ||
fi | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
opensips/python-opensips:latest | ||
opensips/python-opensips:${{ env.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,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/python-opensips | ||
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,10 @@ | ||
FROM python:3.9-slim-buster | ||
LABEL maintainer="Darius Stefan <darius.stefan@opensips.org>" | ||
|
||
RUN pip install opensips | ||
|
||
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 "$@" |