#!/usr/bin/perl
use warnings;
use strict;

my $name = 'perl-cgi';
my $version = '1.0.2';

my $sh_build = <<SHELL;
docker build --pull -f "Dockerfile" -t $name:$version .
SHELL

my $sh_run = <<SHELL;
docker run -d --name=$name --network=skynet --restart=always
-p 9998:80
-v /media/elex/UltraFit/Workspace/ELEX/perl-examples/src/cgi/vhost.conf:/etc/nginx/conf.d/default.conf
-v /media/elex/UltraFit/Workspace/ELEX/perl-examples/src/cgi:/var/www
-e TZ=Asia/Seoul
-e LANG=ko_KR.UTF-8
--log-opt max-size=10m --log-opt max-file=3
$name:$version
SHELL

if ($ARGV[0] eq 'build') {
    system($sh_build);
} elsif ($ARGV[0] eq 'run') {
    $sh_run =~ tr/\n/ /;
    system($sh_run);
}