Public | Automated Build

Last pushed: 2 years ago
Short Description
App service perl
Full Description

Azure has recently announced App Services on Linux. It supports running web apps natively on Linux. You can quickly create an app following Link and setup continuous deployment to publish the app.

Web Apps on Linux is built using Docker. So you can use a Custom Docker image to deploy your web app to an application stack that is not already defined in Azure - Link

This Blog would provide an overview of Creating and running Custom Container to run perl application in web apps on Linux.

Creating Custom Perl Container

  1. I would recommend to setup a local Docker dev environment for creating Custom container(makes it easy to debug). Refer my another blog Running Docker on Azure VM
  2. Make sure your Docker file is running as expected in development environment
  3. Deploy your Docker files into Github. Ex: appserviceperl
  4. Create DockerHub account and Setup Continuous integration from Github

Below are list of steps my DockerFile has to create App Service Perl image
Github Repo :

  • I have extended httpd official container and set custom httpd.conf file
    FROM httpd:2.4
    COPY ./my-httpd.conf /usr/local/apache2/conf/httpd.conf
  • Established symlinks for below as all our site content would be in /home/site/wwwroot folder<br>
    /usr/local/apache2/htdocs -> /home/site/wwwroot<br>
    /usr/local/apache2/logs -> /home/LogFiles<br>
    RUN  rm -f /usr/local/apache2/logs/* \
     && chmod 777 /usr/local/apache2/logs \
     && rm -rf /usr/local/apache2/htdocs \
     && rm -rf /usr/local/apache2/logs \
     && mkdir -p /home/site/wwwroot \
     && mkdir -p /home/LogFiles \
     && chown -R root:www-data /home \
     && ln -s /home/site/wwwroot /usr/local/apache2/htdocs \
     && ln -s /home/LogFiles /usr/local/apache2/logs
  • Installed perl again as cpanm fails with default installation.
    RUN apt-get update \
     && apt-get install make \
     && apt-get install -y perl
  • Created a /home/cpan directory for temporary use and need to be deleted later
    RUN mkdir -p /home/cpan
  • Copied cpanfile to /home/cpan/cpanfile. this file has required perl dependencies. You can alter this as per your requirement.
    COPY ./cpanfile /home/cpan/cpanfile
  • Download cpanm inside /home/cpan folder and insall modules listed in cpanfile

    RUN apt-get install -y curl \
     && cd /home/cpan \
     && curl -LO \
     && apt-get install -y libhtml-parser-perl \
     && perl cpanm --force --installdeps .
  • deleting /home/cpan folder as we don't need it anymore

    RUN rm -rf /home/cpan

    ####Installing Custom Container to run Perl App on Web Apps Linux

  • Navigate to azure portal and select "Web App On Linux" option inside Web + Mobile

  • We need to Select "Configure container" option to use Custom Container
  • Here you can use Built-in container or one from Docker Hub/Private registry
  • I have my Perl Custom Container @ Docker Hub - prashanthmadi/appserviceperl
  • So, I have selected Docker Hub and entered my Image name.
  • Finish the process by pressing Create Button

####Testing App:

  • Create a file with below content and deploy it using FTP/Git.
    #!/usr/bin/perl -w
    print "Content-type: text/html\n\n";
    print "Hello, World.";
  • Navigate to http://<your_webapp_name> and it should show "Hello World"

####Extending Custom Container to install more Perl dependencies
For adding extra modules, make a fork of my github repo.

change content in cpanfile (samples available at below link)…

Publish your new project to dockerhub and use it while configuring container.

Docker Pull Command
Source Repository