Asterisk is a powerful freebase PBX providing VoIP and _Telephony solutions, _catering to the needs of both Enterprise and Stand-Alone levels. In the article below, we would demonstrate the creation of a highly-scalable Asterisk cloud server through Fargate task, which would require minimal maintenance and administration.
Shell
#base image for container
FROM debian:buster-slim
We have chosen Debian Buster Slim for the base image as shown above. It is recommended that you keep the container light and use smallest size for the base image. You can also choose Alpine, Jessie or Stretch versions as per your convenience.
Shell
#base image for container
$ docker build -t asterisk:latest
Sending build context to Docker daemon 2.048kBStep 1/1 : FROM debian:buster-slim: Pulling from library/debian8ec398bc0356: Pull completeDigest: sha256:e4c1417236abc57971755ca2bfccd546cbca45b33daf66001a5addae4bf78517Status: Downloaded newer image for debian:buster-slim---> e1af56d072b8Successfully built e1af56d072b8Successfully tagged asterisk:latest
Use docker build -t asterisk
to setup Asterisk on the Docker image.
Shell
$docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> a8b00d3e8229 37 minutes ago 592MB
asterisk latest e1af56d072b8 2 weeks ago 69.2MB
debian buster-slim e1af56d072b8 2 weeks ago 69.2MB
debian latest b5d2d9b1597b 2 weeks ago 114MB
As shown above, Asteriskis installedwith image id **e1af56d072b8 **showing the image size of 69.2 MB which is tiny compared to the overall ISO size.
Shell
#base image for container
FROM debian:buster-slim
LABEL maintainer="Bora Ozkan <boraozkan@gmail.com>"
Once the labeling is done, you can run docker inspect
to do a quick inspection of the Docker image as shown below.
Shell
$docker inspect asterisk:latest
[
{
"Id": "sha256:d216cbd1c686b8afbcaab3406adf02a8ac481797510ea5a189ac1314ae654ead",
"RepoTags": [
"asterisk:latest"
],
"RepoDigests": [],
"Parent": "sha256:e1af56d072b8d93fce4b566f4bf76311108dbbbe952b12a85418bd32c2fcdda7",
"Comment": "",
"Created": "2020-01-14T09:06:47.708064046Z",
"Container": "d552618057cb929857b2c9dbd1efa2f2be9d7e422c7ab85ff858fa2064398cb1",
"ContainerConfig": {
"Hostname": "d552618057cb",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"LABEL maintainer=Bora OZKAN <boraozkan@gmail.com>"
],
"ArgsEscaped": true,
"Image": "sha256:e1af56d072b8d93fce4b566f4bf76311108dbbbe952b12a85418bd32c2fcdda7",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"maintainer": "Bora OZKAN <boraozkan@gmail.com>"
}
},
"DockerVersion": "18.09.7",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"bash"
],
"ArgsEscaped": true,
"Image": "sha256:e1af56d072b8d93fce4b566f4bf76311108dbbbe952b12a85418bd32c2fcdda7",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"maintainer": "Bora OZKAN <boraozkan@gmail.com>"
}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 69208427,
"VirtualSize": 69208427,
"GraphDriver": {
"Data": {
"MergedDir": "/var/lib/docker/overlay2/495f15d329ebee16bec4985ea625d8d835be42adac19cf075a3b998535bbd58e/merged",
"UpperDir": "/var/lib/docker/overlay2/495f15d329ebee16bec4985ea625d8d835be42adac19cf075a3b998535bbd58e/diff",
"WorkDir": "/var/lib/docker/overlay2/495f15d329ebee16bec4985ea625d8d835be42adac19cf075a3b998535bbd58e/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:556c5fb0d91b726083a8ce42e2faaed99f11bc68d3f70e2c7bbce87e7e0b3e10"
]
},
"Metadata": {
"LastTagTime": "2020-01-14T09:06:47.718230311Z"
}
}
]
Shell
#base image for container
FROM debian:buster-slim
LABEL maintainer='Bora Ozkan <boraozkan@gmail.com>'
ENV ASTERISK_VERSION 17-current
ENV OPUS_CODEC asterisk-17.0/x86-64/codec_opus-17.0_current-x86_64
The **ENV**
instruction sets the environment variable which is important while installing Asterisk. Above we have created two environment values; first is defining the version while the second is for using Default Codec.
Shell
#base image for container
FROM debian:buster-slim
LABEL maintainer='Bora Ozkan <boraozkan@gmail.com>'
ENV ASTERISK_VERSION 17-current
ENV OPUS_CODEC asterisk-17.0/x86-64/codec_opus-17.0_current-x86_64
COPY build-asterisk.sh /
RUN /build-asterisk.sh
The **COPY**
instruction copies files to the image directory as specified while building image, while the **RUN**
instruction will execute any commands in a new layer on top of the current image and commit results.
Now we can create our **build-asterisk.sh**
#docker #aws #cloud native #fargate