前提・実現したいこと
今までローカルで開発を行っており、docker composeを使っていました。そしていざ本番にアップロードしようと思い、AWSを初めて使用しました。調べたところecs-cliを使ってdocker-composeをそのまま本番環境で作れるとあり、試したのですがエラーが出て、解決できません。
発生している問題・エラーメッセージ
$ ecs-cli compose --file docker-compose.yml up ERRO[0000] Unable to open ECS Compose Project error="3 error(s) decoding:\n\n* error decoding 'Volumes[1]': invalid spec: :/var/log/nginx: empty section between colons\n* error decoding 'Volumes[2]': invalid spec: :/etc/nginx/sites-available: empty section between colons\n* error decoding 'Volumes[3]': invalid spec: :/etc/nginx/ssl: empty section between colons" FATA[0000] Unable to create and read ECS Compose Project error="3 error(s) decoding:\n\n* error decoding 'Volumes[1]': invalid spec: :/var/log/nginx: empty section between colons\n* error decoding 'Volumes[2]': invalid spec: :/etc/nginx/sites-available: empty section between colons\n* error decoding 'Volumes[3]': invalid spec: :/etc/nginx/ssl: empty section between colons"
該当のソースコード
以下がdocker-compose.ymlファイルです。
version: '3' networks: frontend: driver: ${NETWORKS_DRIVER} backend: driver: ${NETWORKS_DRIVER} volumes: mysql: driver: ${VOLUMES_DRIVER} phpmyadmin: driver: ${VOLUMES_DRIVER} services: ### Workspace Utilities ################################## workspace: build: context: ./workspace args: - LARADOCK_PHP_VERSION=${PHP_VERSION} - LARADOCK_PHALCON_VERSION=${PHALCON_VERSION} - INSTALL_SUBVERSION=${WORKSPACE_INSTALL_SUBVERSION} - INSTALL_XDEBUG=${WORKSPACE_INSTALL_XDEBUG} - INSTALL_PHPDBG=${WORKSPACE_INSTALL_PHPDBG} - INSTALL_BLACKFIRE=${INSTALL_BLACKFIRE} - INSTALL_SSH2=${WORKSPACE_INSTALL_SSH2} - INSTALL_GMP=${WORKSPACE_INSTALL_GMP} - INSTALL_SOAP=${WORKSPACE_INSTALL_SOAP} - INSTALL_LDAP=${WORKSPACE_INSTALL_LDAP} - INSTALL_IMAP=${WORKSPACE_INSTALL_IMAP} - INSTALL_MONGO=${WORKSPACE_INSTALL_MONGO} - INSTALL_AMQP=${WORKSPACE_INSTALL_AMQP} - INSTALL_PHPREDIS=${WORKSPACE_INSTALL_PHPREDIS} - INSTALL_MSSQL=${WORKSPACE_INSTALL_MSSQL} - INSTALL_NODE=${WORKSPACE_INSTALL_NODE} - NPM_REGISTRY=${WORKSPACE_NPM_REGISTRY} - INSTALL_YARN=${WORKSPACE_INSTALL_YARN} - INSTALL_NPM_GULP=${WORKSPACE_INSTALL_NPM_GULP} - INSTALL_NPM_BOWER=${WORKSPACE_INSTALL_NPM_BOWER} - INSTALL_NPM_VUE_CLI=${WORKSPACE_INSTALL_NPM_VUE_CLI} - INSTALL_DRUSH=${WORKSPACE_INSTALL_DRUSH} - INSTALL_DRUPAL_CONSOLE=${WORKSPACE_INSTALL_DRUPAL_CONSOLE} - INSTALL_AEROSPIKE=${WORKSPACE_INSTALL_AEROSPIKE} - AEROSPIKE_PHP_REPOSITORY=${AEROSPIKE_PHP_REPOSITORY} - INSTALL_V8JS=${WORKSPACE_INSTALL_V8JS} - COMPOSER_GLOBAL_INSTALL=${WORKSPACE_COMPOSER_GLOBAL_INSTALL} - COMPOSER_REPO_PACKAGIST=${WORKSPACE_COMPOSER_REPO_PACKAGIST} - INSTALL_WORKSPACE_SSH=${WORKSPACE_INSTALL_WORKSPACE_SSH} - INSTALL_LARAVEL_ENVOY=${WORKSPACE_INSTALL_LARAVEL_ENVOY} - INSTALL_LARAVEL_INSTALLER=${WORKSPACE_INSTALL_LARAVEL_INSTALLER} - INSTALL_DEPLOYER=${WORKSPACE_INSTALL_DEPLOYER} - INSTALL_PRESTISSIMO=${WORKSPACE_INSTALL_PRESTISSIMO} - INSTALL_LINUXBREW=${WORKSPACE_INSTALL_LINUXBREW} - INSTALL_MC=${WORKSPACE_INSTALL_MC} - INSTALL_SYMFONY=${WORKSPACE_INSTALL_SYMFONY} - INSTALL_PYTHON=${WORKSPACE_INSTALL_PYTHON} - INSTALL_IMAGE_OPTIMIZERS=${WORKSPACE_INSTALL_IMAGE_OPTIMIZERS} - INSTALL_IMAGEMAGICK=${WORKSPACE_INSTALL_IMAGEMAGICK} - INSTALL_TERRAFORM=${WORKSPACE_INSTALL_TERRAFORM} - INSTALL_DUSK_DEPS=${WORKSPACE_INSTALL_DUSK_DEPS} - INSTALL_PG_CLIENT=${WORKSPACE_INSTALL_PG_CLIENT} - INSTALL_PHALCON=${WORKSPACE_INSTALL_PHALCON} - INSTALL_SWOOLE=${WORKSPACE_INSTALL_SWOOLE} - INSTALL_LIBPNG=${WORKSPACE_INSTALL_LIBPNG} - INSTALL_IONCUBE=${WORKSPACE_INSTALL_IONCUBE} - PUID=${WORKSPACE_PUID} - PGID=${WORKSPACE_PGID} - CHROME_DRIVER_VERSION=${WORKSPACE_CHROME_DRIVER_VERSION} - NODE_VERSION=${WORKSPACE_NODE_VERSION} - YARN_VERSION=${WORKSPACE_YARN_VERSION} - DRUSH_VERSION=${WORKSPACE_DRUSH_VERSION} - TZ=${WORKSPACE_TIMEZONE} - BLACKFIRE_CLIENT_ID=${BLACKFIRE_CLIENT_ID} - BLACKFIRE_CLIENT_TOKEN=${BLACKFIRE_CLIENT_TOKEN} volumes: - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER} extra_hosts: - "dockerhost:${DOCKER_HOST_IP}" ports: - "${WORKSPACE_SSH_PORT}:22" tty: true environment: - PHP_IDE_CONFIG=${PHP_IDE_CONFIG} networks: - frontend - backend ### PHP-FPM ############################################## php-fpm: build: context: ./php-fpm args: - LARADOCK_PHP_VERSION=${PHP_VERSION} - LARADOCK_PHALCON_VERSION=${PHALCON_VERSION} - INSTALL_XDEBUG=${PHP_FPM_INSTALL_XDEBUG} - INSTALL_PHPDBG=${PHP_FPM_INSTALL_PHPDBG} - INSTALL_BLACKFIRE=${INSTALL_BLACKFIRE} - INSTALL_SSH2=${PHP_FPM_INSTALL_SSH2} - INSTALL_SOAP=${PHP_FPM_INSTALL_SOAP} - INSTALL_IMAP=${PHP_FPM_INSTALL_IMAP} - INSTALL_MONGO=${PHP_FPM_INSTALL_MONGO} - INSTALL_AMQP=${PHP_FPM_INSTALL_AMQP} - INSTALL_MSSQL=${PHP_FPM_INSTALL_MSSQL} - INSTALL_ZIP_ARCHIVE=${PHP_FPM_INSTALL_ZIP_ARCHIVE} - INSTALL_BCMATH=${PHP_FPM_INSTALL_BCMATH} - INSTALL_GMP=${PHP_FPM_INSTALL_GMP} - INSTALL_PHPREDIS=${PHP_FPM_INSTALL_PHPREDIS} - INSTALL_MEMCACHED=${PHP_FPM_INSTALL_MEMCACHED} - INSTALL_OPCACHE=${PHP_FPM_INSTALL_OPCACHE} - INSTALL_EXIF=${PHP_FPM_INSTALL_EXIF} - INSTALL_AEROSPIKE=${PHP_FPM_INSTALL_AEROSPIKE} - AEROSPIKE_PHP_REPOSITORY=${AEROSPIKE_PHP_REPOSITORY} - INSTALL_MYSQLI=${PHP_FPM_INSTALL_MYSQLI} - INSTALL_PGSQL=${PHP_FPM_INSTALL_PGSQL} - INSTALL_PG_CLIENT=${PHP_FPM_INSTALL_PG_CLIENT} - INSTALL_INTL=${PHP_FPM_INSTALL_INTL} - INSTALL_GHOSTSCRIPT=${PHP_FPM_INSTALL_GHOSTSCRIPT} - INSTALL_LDAP=${PHP_FPM_INSTALL_LDAP} - INSTALL_PHALCON=${PHP_FPM_INSTALL_PHALCON} - INSTALL_SWOOLE=${PHP_FPM_INSTALL_SWOOLE} - INSTALL_IMAGE_OPTIMIZERS=${PHP_FPM_INSTALL_IMAGE_OPTIMIZERS} - INSTALL_IMAGEMAGICK=${PHP_FPM_INSTALL_IMAGEMAGICK} - INSTALL_CALENDAR=${PHP_FPM_INSTALL_CALENDAR} - INSTALL_FAKETIME=${PHP_FPM_INSTALL_FAKETIME} - INSTALL_IONCUBE=${PHP_FPM_INSTALL_IONCUBE} volumes: - ./php-fpm/php${PHP_VERSION}.ini:/usr/local/etc/php/php.ini - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER} expose: - "9000" extra_hosts: - "dockerhost:${DOCKER_HOST_IP}" environment: - PHP_IDE_CONFIG=${PHP_IDE_CONFIG} - DOCKER_HOST=tcp://docker-in-docker:2375 - FAKETIME=${PHP_FPM_FAKETIME} depends_on: - workspace networks: - backend links: - docker-in-docker ### NGINX Server ######################################### nginx: build: context: ./nginx args: - PHP_UPSTREAM_CONTAINER=${NGINX_PHP_UPSTREAM_CONTAINER} - PHP_UPSTREAM_PORT=${NGINX_PHP_UPSTREAM_PORT} - CHANGE_SOURCE=${CHANGE_SOURCE} volumes: - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER} - ${NGINX_HOST_LOG_PATH}:/var/log/nginx - ${NGINX_SITES_PATH}:/etc/nginx/sites-available - ${NGINX_SSL_PATH}:/etc/nginx/ssl ports: - "${NGINX_HOST_HTTP_PORT}:80" - "${NGINX_HOST_HTTPS_PORT}:443" depends_on: - php-fpm networks: - frontend - backend ### MySQL ################################################ mysql: build: context: ./mysql args: - MYSQL_VERSION=${MYSQL_VERSION} environment: - MYSQL_DATABASE=${MYSQL_DATABASE} - MYSQL_USER=${MYSQL_USER} - MYSQL_PASSWORD=${MYSQL_PASSWORD} - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} - TZ=${WORKSPACE_TIMEZONE} volumes: - ${DATA_PATH_HOST}/mysql:/var/lib/mysql - ${MYSQL_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d ports: - "${MYSQL_PORT}:3306" networks: - backend ### phpMyAdmin ########################################### phpmyadmin: build: ./phpmyadmin environment: - PMA_ARBITRARY=1 - MYSQL_USER=${PMA_USER} - MYSQL_PASSWORD=${PMA_PASSWORD} - MYSQL_ROOT_PASSWORD=${PMA_ROOT_PASSWORD} ports: - "${PMA_PORT}:80" depends_on: - "${PMA_DB_ENGINE}" networks: - frontend - backend ### Docker-in-Docker ################################################ docker-in-docker: image: docker:dind privileged: true volumes: - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER} expose: - 2375 networks: - backend
補足情報(FW/ツールのバージョンなど)
$ ecs-cli --version ecs-cli version 1.12.1 (e70f1b1)
回答1件
1
ベストアンサー
docker-compose.yml
はLARADOCKの流用ですよね。
うまくいかないのは
AWSを初めて使用
する人が他人の書いたdocker-compose設定ファイル
でECSデプロイしようとすることが単に無謀だからです。まずはチュートリアルでごく簡単な例から始めて下さい。
https://aws.amazon.com/jp/ecs/getting-started/
調べたところecs-cliを使ってdocker-composeをそのまま本番環境で作れるとあり
開発環境で動作するものをそのままデプロイできるものではありません。
docker-compose.yml
に近い記法で設定ファイルが書ける程度のものと認識下さい。
Nginx等のWebサーバ・Laravel・Docker・ECS全ての理解が必須であり、docker-compose.yml
を使ったデプロイは(恐らく)貴方が想像しているような簡単なものではないです。ちなみに私はAWSのサービスの中でもECSはやや敷居が高いと思っています。
少なくとも下記ができる状態でないと挑戦は難しいでしょう。NginxとPHP-FPMのセットアップ 自分で1からDockerfileとdocker-compose.ymlを書いてLaravelの開発環境を作る DockerHubやECRに自作のDockerイメージを保存 AWSのロードバランサの最低限の理解