php - 如何在 Docker 容器中升级 PHP Alpine
问题描述
基本上,我有 laravel 版本 8 和护照版本 10 用于身份验证。当我尝试在 nginx 终端内安装护照时遇到问题。
php artisan passport:install
错误说我的 php 版本是 7.3.26 而 Passport 需要 php 7.4
这是我的 Dockerfile 的样子:
FROM composer:2 as vendor
COPY . .
RUN composer install \
--ignore-platform-reqs \
--no-interaction \
--no-plugins \
--no-progress \
--no-dev \
--no-scripts \
--prefer-dist \
&& find /app -type d -exec chmod -R 555 {} ; \
&& find /app -type f -exec chmod -R 444 {} ; \
&& find /app/storage -type d -exec chmod -R 755 {} ; \
&& find /app/storage -type f -exec chmod -R 644 {} ;
RUN composer dump-autoload
FROM existenz/webstack:7.4-codecasts
EXPOSE 80
EXPOSE 443
COPY --from=vendor --chown=php:nginx /app /www
# https://github.com/docker-library/php/issues/240
RUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php
RUN apk -U --no-cache add \
php7 php7-zip php7-json php7-openssl php7-curl \
php7-zlib php7-xml php7-phar php7-intl php7-dom php7-xmlreader php7-xmlwriter php7-ctype \
php7-mbstring php7-gd php7-session php7-pdo php7-pdo_mysql php7-tokenizer php7-posix \
php7-fileinfo php7-opcache php7-cli php7-mcrypt php7-pcntl php7-iconv php7-simplexml
如何将我的 php 版本升级到 7.4,或者最坏的情况下我必须降级 laravel 和护照版本。
解决方案
You can install it using this commands:
FROM php:7.4-fpm-alpine
RUN apk add --update --no-cache libgd libpng-dev libjpeg-turbo-dev freetype-dev
RUN docker-php-ext-install -j$(nproc) gd
ADD php.ini /usr/local/etc/php.ini
Or you can follow this article
推荐阅读
- python - 需要帮助解决 Project Euler 问题 #35 python?
- python - 使用 python pandas 中的列位置/编号转换为日期时间
- android - fetch SyntaxError: Unexpected token U in JSON at position 0 in react native Android
- php - 我想打印数字模式程序,但它不会给我错误的输出
- python - Azure App Service:在容器端指定 docker run 端口
- sql - Postgress to_date 和提取组合
- javascript - 使用 React 动态导入文件
- javascript - 仅在选项卡关闭时使用 beforeunload
- loops - 如何在不运行以下脚本的情况下退出循环
- sql - 尝试在 SQL DEVELOPER 上创建表时出现问题