How to write the stack file for Docker Cloud?

Viewed 144

My main goal is to deploy my Laravel 5.1 site into my docker cloud with via docker stack.

  • I already connect my DockerCloud account with my AWS account.
  • I already have :

    1. docker-compose.yml
    2. app.dockerfile
    3. web.dockerfile

docker-compose.yml

version: '2'
services:
# The Application
app:
  build:
    context: ./
    dockerfile: app.dockerfile
  working_dir: /var/www
  volumes:
    - ./:/var/www
  environment:
    - "DB_PORT=3306"
    - "DB_HOST=45.55.88.57"

# The Web Server
web:
  build:
    context: ./
    dockerfile: web.dockerfile
  working_dir: /var/www
  volumes_from:
    - app
  ports:
    - 85:80
volumes:
dbdata:

app.dockerfile

FROM php:7.0.4-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev \
      mysql-client libmagickwand-dev --no-install-recommends \
      && pecl install imagick \
      && docker-php-ext-enable imagick \
      && docker-php-ext-install mcrypt pdo_mysql

web.dockerfile

  FROM nginx:1.10
  ADD vhost.conf /etc/nginx/conf.d/default.conf

vhost.conf

 server {
      listen 80;
      index index.php index.html;
      root /var/www/public;

      location / {
          try_files $uri /index.php?$args;
      }

      location ~ \.php$ {
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          fastcgi_pass app:9000;
          fastcgi_index index.php;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_param PATH_INFO $fastcgi_path_info;
      }
  }

Result

enter image description here

http://localhost:85

It is working perfectly fine on local.

enter image description here

Goal

enter image description here

With all the docker files I got, how do I write the stack file for Docker Cloud ?

1 Answers

I would try Elastic Beanstalk. Please look here. So you need to rework docker-compose.yml to Dockerrun.aws.json.

Related