简体   繁体   English

如何在 Docker 容器中升级 PHP Alpine

[英]How to upgrade PHP Alpine in Docker Container

Basically, i have laravel version 8 and passport version 10 for authentication.基本上,我有 laravel 版本 8 和护照版本 10 用于身份验证。 i have a problem when i try to install passport inside nginx terminal.当我尝试在 nginx 终端内安装护照时遇到问题。 php artisan passport:install

The Error Said my php version was 7.3.26 while Passport needs php 7.4错误说我的 php 版本是 7.3.26 而 Passport 需要 php 7.4

Here is my Dockerfile looks like:这是我的 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

How can i upgrade my php version to 7.4, or maybe the worst case i have to downgrade laravel and passport version.如何将我的 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或者你可以关注这篇文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM