From e77fad4173e016f8166fc26e862c3933996ba03b Mon Sep 17 00:00:00 2001 From: Alessandro DiMarco Date: Thu, 12 Jan 2017 15:57:54 -0500 Subject: [PATCH 1/2] Add dockerfile --- Dockerfile | 43 ++++++++++++++++++++++++++++++++++++++++++ Dockerrun.aws.json | 16 ++++++++++++++++ config/nginx.conf | 29 ++++++++++++++++++++++++++++ config/supervisor.conf | 2 ++ 4 files changed, 90 insertions(+) create mode 100644 Dockerfile create mode 100644 Dockerrun.aws.json create mode 100644 config/nginx.conf create mode 100644 config/supervisor.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..e14c39ef --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM ubuntu + +ENV CODEROOT=/home/docker/code + +# Log enironment variables. +ENV NGINXERR=/var/log/nginx.err.log +ENV NGINXREQ=/var/log/nginx.req.log + +# Custom environment variables. These change from project to project. +ARG DOMAIN +ENV DOMAIN=${DOMAIN} + +# Install dependencies. +RUN \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + nginx supervisor \ + build-essential git && \ + rm -rf /var/lib/apt/lists/* + +# Put the code somewhere. +ADD . $CODEROOT/ + +# Create the www user. +RUN useradd -ms /bin/bash www + +# Create the log files. +RUN touch $NGINXERR && touch $NGINXREQ + +# Copy the configuration files, inserting environment variables along the way. +RUN \ + replace_vars() { \ + echo "Copying environment variables from $1 to $2."; \ + sed -e "s/\$DOMAIN/$DOMAIN/g" \ + -e "s@\$CODEROOT@$CODEROOT@g" \ + -e "s@\$NGINXERR@$NGINXERR@g" \ + -e "s@\$NGINXREQ@$NGINXREQ@g" $1 > $2; \ + }; \ + replace_vars $CODEROOT/config/nginx.conf /etc/nginx/nginx.conf && \ + replace_vars $CODEROOT/config/supervisor.conf /etc/supervisor/conf.d/supervisor.conf + +EXPOSE 80 +CMD ["supervisord", "-n"] \ No newline at end of file diff --git a/Dockerrun.aws.json b/Dockerrun.aws.json new file mode 100644 index 00000000..f62e9284 --- /dev/null +++ b/Dockerrun.aws.json @@ -0,0 +1,16 @@ +{ + "AWSEBDockerrunVersion": "1", + "Authentication": { + "Bucket": "dockerauth.blocpower.org", + "Key": "$DOCKER_REPO.json" + }, + "Image": { + "Name": "blocp/$DOCKER_REPO" + }, + "Ports": [ + { + "HostPort": "80", + "ContainerPort": "80" + } + ] +} \ No newline at end of file diff --git a/config/nginx.conf b/config/nginx.conf new file mode 100644 index 00000000..e733b12d --- /dev/null +++ b/config/nginx.conf @@ -0,0 +1,29 @@ +daemon off; +user www; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + gzip on; + charset utf-8; + client_max_body_size 10M; + + access_log $NGINXREQ; + error_log $NGINXERR; + + server { + listen 80; + listen [::]:80; + server_name $DOMAIN www.$DOMAIN; + location / { + root $CODEROOT/build; + try_files $uri$args $uri$args/ $uri/ /index.html =404; + } + } +} \ No newline at end of file diff --git a/config/supervisor.conf b/config/supervisor.conf new file mode 100644 index 00000000..22f88b5f --- /dev/null +++ b/config/supervisor.conf @@ -0,0 +1,2 @@ +[program:nginx] +command = /usr/sbin/nginx \ No newline at end of file -- GitLab From d0da45234b88b126a7d4908930b8b6de4bc8e0b7 Mon Sep 17 00:00:00 2001 From: Alessandro DiMarco Date: Thu, 12 Jan 2017 16:21:17 -0500 Subject: [PATCH 2/2] Add elasticbeanstalk yml --- .elasticbeanstalk/config.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .elasticbeanstalk/config.yml diff --git a/.elasticbeanstalk/config.yml b/.elasticbeanstalk/config.yml new file mode 100644 index 00000000..9c857cdf --- /dev/null +++ b/.elasticbeanstalk/config.yml @@ -0,0 +1,12 @@ +branch-defaults: + $GIT_BRANCH: + environment: $EB_ENV +global: + application_name: $EB_APP + default_ec2_keyname: EastCoastBPKey + default_platform: 64bit Amazon Linux 2015.09 v2.0.8 running Docker 1.9.1 + default_region: us-east-1 + profile: null + sc: git +deploy: + artifact: deployment.zip \ No newline at end of file -- GitLab