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

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
5
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

Organization

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

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拡張を入れられる世界線に行きたい...

参考

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
5
Help us understand the problem. What are the problem?