Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying Perl Docker Container to Elastic Beanstalk

I am building a Docker container that pulls a perl/mojolicious repo from bitbucket but I am having problems. I have my Dockerfile like this:

# DOCKER-VERSION 0.3.4
FROM        perl:latest
MAINTAINER  My Name [email protected]

# Update aptitude with new repo
RUN apt-get update

# Install software 
RUN apt-get install -y git
# Make ssh dir
RUN mkdir /root/.ssh/

# Copy over private key, and set permissions
ADD repo-key /root/.ssh/id_rsa

# Create known_hosts
RUN touch /root/.ssh/known_hosts
# Add bitbuckets key
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts

RUN curl -L http://cpanmin.us | perl - App::cpanminus
RUN cpanm Mojolicious

RUN cachebuster=b953b35 git clone -b branch [email protected]:org/project.git

EXPOSE 8080

WORKDIR project
CMD hypnotoad script/project

And, locally, upon docker build -t name/project . it builds fine and says "Successfully built."

I zipped it with the repo-key file and fed that to Elastic Beanstalk, I clicked Upload and Deploy (I successfully deployed the 2048 game sample, and tried to replicate it).

This comes back with Dockerrun.aws.json: No such file or directory. Which I think is strange because the documentation says Dockerfile or Dockerrun.aws.json can be used independently for different needs. But whatever, I gave it a short, hopefully inconsequential, Dockerrun.aws.json, like so:

{
    "AWSEBDockerrunVersion": "1",
    "Ports": [
        {"ContainerPort": "8080"}
    ],
    "Volumes": []
}

It still fails and the log now states [CMD-AppDeploy/AppDeployStage0/AppDeployPreHook/04run.sh] command failed with error code 1: and further Docker container quit unexpectedly after launch.

Can someone help me troubleshoot these files?

like image 546
Iluvatar14 Avatar asked Apr 14 '15 20:04

Iluvatar14


1 Answers

I figured it out. The problem was that hypnotoad runs in the background by default and this makes the container die instantly. By adding the -f flag, it runs in the foreground and the container persists. I also switched CMD to ENTRYPOINT.

#... same as above except for last line

WORKDIR project
ENTRYPOINT [ "hypnotoad", "-f", "./script/project" ]

You still have to feed EB both Dockerfile and Dockerrun.aws.json for no apparent reason, but even so, it works without error.

like image 75
Iluvatar14 Avatar answered Sep 30 '22 16:09

Iluvatar14