Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@

# Go workspace file
go.work
.env
.env

log.txt
main
12 changes: 12 additions & 0 deletions dev/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## for Asterisk only
AMI_HOST=155.138.131.82
AMI_PORT=5038
AMI_USER=ami
AMI_PASS=123

ARI_USERNAME=ariuser
ARI_PASSWORD=myaripassword

LINEBLOCS_KEY=123

VERSION=master
93 changes: 93 additions & 0 deletions dev/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Use Docker Compose to develop lineblocs - ari-apps

## Notice
Please make sure use docker compose with minimal version 2.2

## Structure of directory
```shell
ari-apps
├── api
├── bitbucket-pipelines.yml
├── dev
| ├── docker-compose.yaml
| └── entrypoint.sh
| └── README.md
| └── .env
├── Dockerfile
├── entrypoint.sh
├── go.mod
├── go.sum
├── grpc
├── helpers
├── keys
├── lineblocs.proto
├── logger
├── log.txt
├── main
├── main.go
├── mngrs
├── netdiscover
├── README.md
├── router
├── router.proto
├── types
└── utils
asterisk

```

## Simple running
```shell
$ git clone https://github.com/Lineblocs/ari-apps.git
$ cp .env.docker .env
$ cd ari-apps/dev
$ cp .env.example .env
$ docker compose --profile asterisk-cloud up -d
$ docker compose watch
```

## Advance running

### Clone ari-apps project
Clone docker compose and move to directory.
```shell
$ git clone https://github.com/Lineblocs/ari-apps.git
```

### Make .env file and configure
env file for ari-apps
```shell
$ cp .env.docker .env
```
### Move to dev directory
```
$ cd ari-apps/dev
```

### Make .env file and configure
env file for docker compose and asterisk
```shell
$ cp .env.example .env
```

### create container
Create and run container with this command below.

```shell
$ docker compose --profile asterisk-cloud up -d
```

While want to modify asterisk configuration, build asterisk on local. Use profile asterisk-local to do that. Also clone asterisk project, put on same directory with ari-apps project. Create and run container with this command below.
```shell
$ docker compose --profile asterisk-local up -d
$ docker compose watch
```

### Useful command
Check log `docker logs -f lineblocs-ari-apps`

Log in to terminal of container -> `docker exec -it lineblocs-ari-apps bash`

Modify project under `ari-apps` directory

After change configuration, Please run `docker compose restart`
101 changes: 101 additions & 0 deletions dev/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
version: "3.6"
x-logging: &default-logging
options:
max-size: "100m"
max-file: "5"
driver: json-file
services:
ari_apps:
build:
context: ..
dockerfile: Dockerfile
image: lineblocs-ari-apps
logging: *default-logging
container_name: lineblocs-ari-apps
# Please choose, use block of "volumes" or "develop"
# volumes:
# - ..:/app
# - ../netdiscover:/bin/netdiscover
# - ../go.mod:/go.mod
# - ../go.sum:/go.sum
develop:
watch:
- action: sync
path: ..
target: /app
- action: sync+restart
path: ./entrypoint.sh
target: /app/dev/entrypoint.sh
- action: sync+restart
path: ../netdiscover
target: /bin/netdiscover
- action: sync+restart
path: ../go.mod
target: /go.mod
- action: sync+restart
path: ../go.sum
target: /go.sum
- action: rebuild
path: ./Dockerfile
- action: rebuild
path: ./docker-compose.yaml
restart: unless-stopped
# environment:
# - DEPLOYMENT_DOMAIN=${DEPLOYMENT_DOMAIN}
# - ARI_HOST=${ARI_HOST}
# - ARI_PORT=${ARI_PORT}
# - ARI_USERNAME=${ARI_USERNAME}
# - ARI_PASSWORD=${ARI_PASSWORD}
# - ARI_USE_PROXY=${ARI_USE_PROXY}
# - LINEBLOCS_KEY=${LINEBLOCS_KEY}
# - NATSGW_URL=
# - PROXY_HOST=
# - USE_DOTENV=
entrypoint:
sh -c "
/bin/bash ;
/app/dev/entrypoint.sh ;
"
network_mode: "host"

asterisk:
build:
context: ../../asterisk/
dockerfile: Dockerfile
image: lineblocs-asterisk
volumes:
- ../../asterisk/configs:/etc/asterisk/
logging: *default-logging
container_name: lineblocs-asterisk
restart: unless-stopped
environment:
- AMI_USER=${AMI_USER}
- AMI_PASS=${AMI_PASS}
- AMI_PORT=${AMI_PORT}
- AMI_HOST=${AMI_HOST}
- ARI_USERNAME=${ARI_USERNAME}
- ARI_PASSWORD=${ARI_PASSWORD}
- LINEBLOCS_KEY=${LINEBLOCS_KEY}
profiles:
- asterisk-local
network_mode: "host"

asterisk-cloud:
image: lineblocs/asterisk:${VERSION}
# to enable costum config. Please uncomment volumes and that value. Also make sure, you have asterisk project
# volumes:
# - ../../asterisk/configs:/etc/asterisk/
logging: *default-logging
container_name: lineblocs-asterisk-cloud
restart: unless-stopped
environment:
- AMI_USER=${AMI_USER}
- AMI_PASS=${AMI_PASS}
- AMI_PORT=${AMI_PORT}
- AMI_HOST=${AMI_HOST}
- ARI_USERNAME=${ARI_USERNAME}
- ARI_PASSWORD=${ARI_PASSWORD}
- LINEBLOCS_KEY=${LINEBLOCS_KEY}
profiles:
- asterisk-cloud
network_mode: "host"
24 changes: 24 additions & 0 deletions dev/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#! /bin/bash
# determine proxy host to use

if [[ -z "${ARI_URL}" ]]; then
: ${CLOUD=""} # One of aws, azure, do, gcp, or empty
if [ "$CLOUD" != "" ]; then
PROVIDER="-provider ${CLOUD}"
fi

PRIVATE_IPV4=$(netdiscover -field privatev4 ${PROVIDER})
#PRIVATE_IPV4="172.24.0.1"
PUBLIC_IPV4=$(netdiscover -field publicv4 ${PROVIDER})

export PROXY_HOST=${PUBLIC_IPV4}
export ARI_URL="http://${PROXY_HOST}:8088/ari"
export ARI_WSURL="ws://${PROXY_HOST}:8088/ari/events"
fi

cd /app
go mod download

go build -o main main.go

./main