Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@honeytrap15

Laravel 5.8 + dockerで新規プロジェクトを作成する

More than 1 year has passed since last update.

dockerコンテナでlaravelのスタータープロジェクトを作成します。

手順

1. ベースイメージの作成

php7.2をベースに composer + laravel 5.8のイメージを作成する

FROM php:7.2-fpm
COPY php.ini /usr/local/etc/php/

RUN apt-get update && \
    apt-get install -y \
    libpq-dev \
    zlib1g-dev && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

RUN pecl install xdebug && docker-php-ext-enable xdebug
RUN docker-php-ext-install zip pdo

# install composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"
RUN mv composer.phar /usr/local/bin/composer

# setup composer
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /composer
ENV PATH $PATH:/composer/vendor/bin
ENV PATH $PATH:/app/vendor/bin

# instal laravel
RUN composer global require "laravel/installer"
$ docker build . -t laravel-base

2. 作成したベースイメージでlaravelアプリケーションを生成する

$ docker run -w / -it laravel-base bash
(laravel-base) # laravel new app
$ docker cp <container id>:/app .

さっきビルドしたlaravel-baseを使って laravel new app コマンドを実行。
出力されたファイルをホストPCにコピーします。

3. 実行

$ docker run -v app:/app -w /app -p 8000:8000 -it laravel-app php artisan serve --port 8000
0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?