7
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

alpine版のPHP公式Dockerfileを使ってphpredisを入れる

Last updated at Posted at 2018-10-06

alpine版のPHP公式Dockerイメージを使って

RUN docker-php-ext-install redis

でphpredisを入れようとしましたが、入ってくれないようです。

ひとまず、下の2つの記事を足して割った方法で、phpredisを入れることが出来ましたので書いておきます。

Dockerfile(シンプル版)
FROM php:7.2.8-fpm-alpine3.7

# gitで落とすので追加
RUN apk add git

# これを叩かないとextensionのディレクトリ(/usr/src/ext)が見れない
RUN docker-php-source extract 

# extensionのディレクトリに、phpredisを任意のブランチでクローンして突っ込む
# (ここでは4.1.1のタグを指定)
RUN git clone -b 4.1.1 --depth 1 https://github.com/phpredis/phpredis.git /usr/src/php/ext/redis && \
    docker-php-ext-install redis
Dockerfile(ちゃんと書くとこんな感じ?)
FROM php:7.2.8-fpm-alpine3.7
RUN apk update && \
    apk --no-cache upgrade && \
    apk add git && \
    docker-php-source extract \
    git clone -b 4.1.1 --depth 1 https://github.com/phpredis/phpredis.git /usr/src/php/ext/redis && \
    docker-php-ext-install redis

まとめ

こんな感じで応用できそうな?
RUN git clone -b 7.4 --depth 1 https://github.com/hoge/hoge.git /usr/src/ext/hoge && \
    git clone -b 5.7 --depth 1 https://github.com/fuga/fuga.git /usr/src/ext/fuga && \
    docker-php-ext-install hoge fuga

composerでC拡張を入れられる世界線に行きたい...

参考

7
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?