Browse Source

..

docker-webrtc
bruno 1 year ago
parent
commit
5384c55aa4
  1. 71
      debian/docker-compose.yml
  2. 18
      debian/pabx/Dockerfile
  3. 47
      debian/pabx/build-asterisk_php.sh
  4. 26
      debian/pabx/config_network
  5. 7
      debian/pabx/etc_asterisk/sip_general.conf
  6. 2
      debian/pabx/supervisord.conf
  7. 23
      debian/postgres-13/Dockerfile
  8. 14
      debian/postgres-13/include_sql.sh
  9. 5
      debian/postgres-13/permission_pg_hba.sh

71
debian/docker-compose.yml vendored

@ -3,12 +3,10 @@ networks:
working:
driver: bridge
services:
postgres:
# valor postgresql_version está definido na env
postgres:
build:
context: postgres-${postgresql_version}
# nome do container com o versão postgresql_version é definido pela env
container_name: v1.7.12-postgres${postgresql_version}
context: postgres-11
container_name: v1.8-postgres11
restart: always
environment:
- POSTGRES_USER=contacte
@ -23,36 +21,39 @@ services:
- ${pasta_do_projeto}/projeto/base:/base
# copiar a pasta /var/lib/pgsql/data
- ${pasta_do_postgresql11}:/var/lib/postgresql/data
aplicativo:
build:
context: pabx
args:
# usar para compilar dockerfile
# DB_HOST DB_PORT DB_BASE - necessário para colocar no crontab
# environment compose é para depois do dockerfile
- DB_HOST=postgres
- DB_PORT=5432
- DB_BASE=pbx
restart: always
container_name: v1.7.12-pabx-debian
working_dir: /var/www/html/
ports:
- 8080:80
- 5038:5038
- "5060:5060/udp"
- "10000-10030:10000-10030/udp"
privileged: true
depends_on:
- postgres
networks:
- working
links:
- postgres
volumes:
- ${pasta_do_projeto}:/var/www/html/aplicativo
- ${pasta_do_projeto}/include:/var/www/html/include
- ${pasta_do_projeto}/asterisk/var_lib_asterisk/:/var/lib/asterisk/
- ${pasta_do_projeto}/asterisk/hdaux_utilitarios_scripts/:/hdaux/utilitarios/scripts
aplicativo:
build:
context: pabx
args:
# usar para compilar dockerfile
# DB_HOST DB_PORT DB_BASE - necessário para colocar no crontab
# environment compose é para depois do dockerfile
- DB_HOST=postgres
- DB_PORT=5432
- DB_BASE=pbx
- IP_HOST=${IP_HOST}
restart: always
environment:
- IP_HOST=${IP_HOST}
container_name: v1.8-pabx-debian
working_dir: /var/www/html/
ports:
- 8080:80
- 5038:5038
- "5060:5060/udp"
- "10000-10030:10000-10030/udp"
privileged: true
depends_on:
- postgres
networks:
- working
links:
- postgres
volumes:
- ${pasta_do_projeto}:/var/www/html/aplicativo
- ${pasta_do_projeto}/include:/var/www/html/include
- ${pasta_do_projeto}/asterisk/var_lib_asterisk/:/var/lib/asterisk/
- ${pasta_do_projeto}/asterisk/hdaux_utilitarios_scripts/:/hdaux/utilitarios/scripts
volumes:
storage:
db:

18
debian/pabx/Dockerfile vendored

@ -8,32 +8,44 @@ FROM debian:stable-slim
ARG DB_HOST
ARG DB_PORT
ARG DB_BASE
ARG IP_HOST
ENV ASTERISK_VERSION 13.18-cert3
ENV ASTERISK_ADDONS_VERSION 13.18-cert3
ENV VERSION_SIMPLESIP v1.7.12
ENV ASTERISK_USER pbx
ENV ASTERISK_GID pbx
ENV VERSION_SIMPLESIP v1.8
ENV APACHE_RUN_USER pbx
ENV APACHE_RUN_GROUP pbx
ENV DB_HOST $DB_HOST
ENV DB_PORT $DB_PORT
ENV DB_BASE $DB_BASE
ENV IP_HOST $IP_HOST
# Instalação do asterisk e do PHP 8.2
COPY build-asterisk_php.sh /
RUN chmod 755 /build-asterisk_php.sh
RUN /build-asterisk_php.sh
COPY etc_asterisk/* /etc/asterisk
RUN printenv | sed 's/^\(.*\)$/export \1/g' > /env_to_crontab.sh
COPY crontab.sh /
RUN sh /crontab.sh
COPY /config_network /
RUN chmod 755 /config_network
RUN bash /config_network
EXPOSE 80/tcp 5038/tcp 5060/udp 5060/tcp 5160/udp 5160/tcp 10000-10030/udp
VOLUME /var/lib/asterisk/sounds /var/lib/asterisk/keys /var/lib/asterisk/phoneprov /var/spool/asterisk /var/log/asterisk
COPY docker-entrypoint.sh /
COPY supervisord.conf /etc/supervisor/supervisord.conf
COPY etc_asterisk/* /etc/asterisk
RUN sed -i "s/rtpend=.*/rtpend=10030/g" /etc/asterisk/rtp.conf
RUN sed -i "s/hostname=.*/hostname=postgres/g" /etc/asterisk/cdr_pgsql.conf
RUN sed -i "s/;nocolor = .*/nocolor = yes/g" /etc/asterisk/asterisk.conf
COPY cnvrtd /etc/init.d/
COPY rtabd /etc/init.d/

47
debian/pabx/build-asterisk_php.sh vendored

@ -9,17 +9,16 @@ fi
set -ex
useradd --system pbx
useradd --system asterisk
apt-get -y update
apt install lsb-release apt-transport-https ca-certificates software-properties-common -y
apt-get install lsb-release apt-transport-https ca-certificates software-properties-common -y
apt-get install wget
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
apt update
apt-get -y update
apt-get install -y \
@ -35,6 +34,7 @@ apt-get install -y \
git \
vim \
apache2 \
libjansson-dev \
ffmpeg \
build-essential \
libedit-dev \
@ -101,24 +101,6 @@ apt-get install -y \
php8.2-pgsql
### INSTALL JANSSON ###
VERSION_JANSSON=jansson-2.11
wget https://digip.org/jansson/releases/${VERSION_JANSSON}.tar.gz
tar -zxf ${VERSION_JANSSON}.tar.gz
cd ${VERSION_JANSSON}
./configure
make
make check
make install
echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf
ldconfig
cd ..
### INSTALL CENTRAL SIMPLES IP ###
sed -i 's/DocumentRoot \/var\/www\/html/DocumentRoot \/var\/www\/html\/aplicativo/g' /etc/apache2/sites-enabled/000-default.conf
@ -157,12 +139,8 @@ make install
make samples
make dist-clean
# set runuser and rungroup
sed -i -E 's/^;(run)(user|group)/\1\2/' /etc/asterisk/asterisk.conf
sed -i -e 's/# MAXFILES=/MAXFILES=/' /usr/sbin/safe_asterisk
chown -R asterisk:asterisk /etc/asterisk \
/var/*/asterisk \
chown -R pbx:pbx /var/*/asterisk \
/usr/*/asterisk \
/usr/lib64/asterisk
chmod -R 750 /var/spool/asterisk
@ -171,8 +149,15 @@ cd /
rm -rf /usr/src/asterisk \
/usr/src/codecs
apt-get clean
apt-get autoremove
sed -i 's/;nocolor = yes/nocolor = yes/g' /etc/asterisk/asterisk.conf
echo "/usr/lib64/" > /etc/ld.so.conf.d/local.conf
ldconfig
apt-get clean
apt-get autoremove -y
apt-get install -y iproute2
### CONFIGURANDO O PHP ###
@ -207,11 +192,5 @@ sed -i 's/^export APACHE_RUN_USER=.*/export APACHE_RUN_USER=pbx/g' /etc/apache2
sed -i 's/^export APACHE_RUN_GROUP=.*/export APACHE_RUN_GROUP=pbx/g' /etc/apache2/envvars
cd /var/www/html/
mkdir -p /hdaux/utilitarios/scripts
### CONFIGURACOES ASTERISK ###
sed -i "s/rtpend=.*/rtpend=10030/g" /etc/asterisk/rtp.conf
sed -i "s/hostname=.*/hostname=postgres/g" /etc/asterisk/cdr_pgsql.conf
exec rm -f /build-asterisk.sh

26
debian/pabx/config_network vendored

@ -0,0 +1,26 @@
#!/bin/bash
echo "---- Configurar PABX SIMPLES IP ----"
if [[ -z $IP_HOST ]];then
echo "Nao definido variavel de ambiente"
exit;
fi
NET_CONTAINER=$(ip route|awk 'NR==2 {print $1}'|awk -F / '{print $1"\/"$2}')
if [[ -z $NET_CONTAINER ]];then
echo "Nao definido variavel de ambiente"
exit;
fi
sed -i "s/;\?externaddr=.*/externaddr=${IP_HOST}/g" /etc/asterisk/sip_general.conf
sed -i "s/;\?localnet=.*/localnet=${NET_CONTAINER}/g" /etc/asterisk/sip_general.conf
sed -i "s/;\?media_address=.*/media_address=${IP_HOST}/g" /etc/asterisk/sip_general.conf
pid_asterisk=$(ps -aux|grep -E "\/usr\/sbin\/asterisk"|awk '{print $2}')
if [[ -z $pid_asterisk ]];then
exit;
fi
kill -9 $pid_asterisk

7
debian/pabx/etc_asterisk/sip_general.conf vendored

@ -9,3 +9,10 @@ minexpiry=60
relaxdtmf=yes
alwaysauthreject=yes
sipdebug=no
; Inserido para funcionar no docker
icesupport=no
localnet=<rede docker>
externaddr=<ip máquina física>
media_address=<ip máquina física>

2
debian/pabx/supervisord.conf vendored

@ -8,7 +8,7 @@ command=chown pbx:pbx -R /etc/asterisk/ /var/lib/asterisk/ /var/www/html && /hda
command=/usr/sbin/apachectl -D BACKGROUND
[program:asterisk]
command=/usr/sbin/asterisk -vvvdddf -T -W -U asterisk -p
command=/usr/sbin/asterisk -vvvdddf -T -W -U pbx -p
[program:cron]
command=/usr/sbin/cron

23
debian/postgres-13/Dockerfile vendored

@ -1,23 +0,0 @@
#postgres:11.5
FROM postgres@sha256:7ffb249ddc0510a5248a019a71710ee222c6204c7c0ccf07f19f2d6cf638f18a
ENV LC_ALL=en_US.ISO-8859-1
ENV LC_MESSAGES=en_US.ISO-8859-1
ENV LC_MONETARY=en_US.ISO-8859-1
ENV LC_NUMERIC=en_US.ISO-8859-1
ENV LC_TIME=en_US.ISO-8859-1
RUN echo "en_US ISO-8859-1" > /etc/locale.gen
RUN locale-gen "en_US ISO-8859-1"
RUN export LC_ALL="en_US ISO-8859-1"
RUN update-locale
COPY include_sql.sh /docker-entrypoint-initdb.d/
RUN chmod 755 /docker-entrypoint-initdb.d/include_sql.sh
EXPOSE 5432
COPY permission_pg_hba.sh /
RUN chmod 755 /permission_pg_hba.sh
RUN /permission_pg_hba.sh

14
debian/postgres-13/include_sql.sh vendored

@ -1,14 +0,0 @@
psql -U contacte -d pbx -f /base/schema/createSchema_1.sql
psql -U contacte -d pbx -f /base/schema/putData.sql
psql -U contacte -d pbx -f /base/schema/whatsapp.sql
psql -U contacte -d pbx -f /base/sql/versao-1.7.11.3.sql
psql -U contacte -d pbx -f /base/sql/versao-1.7.11.4.sql
psql -U contacte -d pbx -f /base/sql/versao-1.7.11.5.sql
psql -U contacte -d pbx -f /base/sql/versao-1.7.12.sql

5
debian/postgres-13/permission_pg_hba.sh vendored

@ -1,5 +0,0 @@
#!/bin/sh
echo "host all all 192.168.115.0/24 password" >> /var/lib/postgresql/data/pg_hba.conf
echo "host all all 10.252.252.0/24 password" >> /var/lib/postgresql/data/pg_hba.conf
echo "host all all 177.67.197.146/32 password" >> /var/lib/postgresql/data/pg_hba.conf
Loading…
Cancel
Save