aokabin / laravel-practice

0 stars 0 forks source link

Docker環境でLaravelを動かす #3

Open aokabin opened 4 years ago

aokabin commented 4 years ago

最新のphpのDocker imageを持ってくる

良さそうじゃない?

aokabin commented 4 years ago

あ、いい感じのページ発見

packagist.jpを使った方がいいという昔の情報から、こういうふうにしてみた

FROM php:7.4.4-fpm-alpine3.11
COPY php.ini /usr/local/etc/php/

RUN apk --no-cache update && \
    apk --no-cache upgrade && \
    apk --no-cache add \
    curl-dev \
    freetype-dev \
    libjpeg-turbo-dev \
    libpng-dev \
    libxml2-dev \
    zlib-dev \
    pcre-dev \
    g++ \
    make \
    autoconf \
    openssl \
    nodejs-npm \
    bash \
  && docker-php-ext-install \
    curl \
    dom \
    mbstring \
    pdo \
    pdo_mysql \
    simplexml \
    zip \
    opcache \
  && docker-php-ext-configure gd \
    --with-freetype-dir=/usr/include/ \
    --with-jpeg-dir=/usr/include/ \
    --with-png-dir=/usr/include/ \
  && docker-php-ext-install gd \
  && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
  && chmod +x /usr/local/bin/composer \
  && rm -rf /var/cache/apk/*

RUN composer global require "laravel/installer" && \
    composer self-update && \
    composer global require hirak/prestissimo && \
    composer config -g repos.packagist composer https://packagist.jp

ENV COMPOSER_ALLOW_SUPERUSER 1

ENV COMPOSER_HOME /composer

ENV PATH $PATH:/composer/vendor/bin
$ docker build .
(中略)
configure: error: Package requirements (oniguruma) were not met:

Package 'oniguruma', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables ONIG_CFLAGS
and ONIG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

onigurumaエラーですわ、なんだっけ、どっかでみた気がする

なるほど、libong-devが必要、と

alpineではoniguruma-devらしい

    pcre-dev \
+   oniguruma-dev \
    g++ \
    make \

追加してみた

aokabin commented 4 years ago

次はlibzipエラーか

configure: error: Package requirements (libzip >= 0.11) were not met:

Package 'libzip', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBZIP_CFLAGS
and LIBZIP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
    oniguruma-dev \
+   libzip-dev \
    g++ \

今度は configure: error: unrecognized options: --with-freetype-dir, --with-jpeg-dir, --with-png-dir

うーん、これは、、、 docker-php-ext-configure コマンドの意味がわかってないかも

aokabin commented 4 years ago

docker-php-ext-configureとdocker-php-ext-installは、コンテナイメージに事前に圧縮されて入っているエクステンションを操作できます。

phpのコンテナ独自のやつかな

エラー文で調べてみる

あ、これかも?


  RUN docker-php-ext-configure gd
- --with-png-dir=/usr/include/
- --with-jpeg-dir=/usr/include/
- --with-freetype-dir=/usr/include/
+ --with-png=/usr/include/
+ --with-jpeg=/usr/include/
+ --with-freetype=/usr/include/
aokabin commented 4 years ago

pngでエラーなったけど、指定しなくてよくなったかも、って書いてあったわ

aokabin commented 4 years ago

お、ビルド通った

aokabin commented 4 years ago

あれ、laravelコマンドが入ってないな... まぁ入ってなくてもいいかもしれないんだけど。。。

いらないのかもしれない

aokabin commented 4 years ago

次はdocker-composeを使って起動させてみる