使用 Dockerfile 更新 php 版本

问题描述 投票:0回答:1

我用作 Github 操作运行程序的 Docker 映像面临一些问题。我使用来自 https://github.com/myoung34/docker-github-actions-runner 的 Docker 镜像作为基础,然后运行一系列命令。

我的 Dockerfile

# base
FROM myoung34/github-runner:latest

# Let's create a nice FAT image with all bells & whistles
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
    && \
    apt-key adv --fetch-keys https://dl.yarnpkg.com/debian/pubkey.gpg \
    && \
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list \
    && \
    add-apt-repository -y ppa:apt-fast/stable \
    && \
    apt-get update \
    && \ 
    apt install -y --no-install-recommends \
    vim \
    apt-utils \
    apt-fast \
    rsync \
    gcc \
    g++ \
    make \
    dh-autoreconf \
    zip \
    php-cli \
    php-curl \
    php-xml \
    php-zip \
    php-mbstring \
    python \
    unzip \
    nodejs \
    yarn \
    phantomjs \
    && \
    apt clean \
    && \
    curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer \
    && \
    npm i -g gulp \
    && \
    mkdir -p /actions-runner/installers

WORKDIR /actions-runner

COPY ./installers /actions-runner/installers
COPY ./ssh /actions-runner/ssh

RUN chmod +x /actions-runner/installers/ssh-keys.sh \
  && chmod +x /actions-runner/installers/google-chrome.sh \
  && /actions-runner/installers/ssh-keys.sh \
  && /actions-runner/installers/google-chrome.sh \
  && rm -rf /actions-runner/installers \
  && rm -rf /actions-runner/ssh \ 
  && rm -rf /var/lib/apt/lists/* \
  && rm -rf /tmp/*

ENV QT_QPA_PLATFORM=offscreen
RUN echo 'alias gsed="sed"' >> ~/.bashrc
RUN echo -e '#!/bin/bash\nsed "$@"' > /usr/bin/gsed && \
    chmod +x /usr/bin/gsed

我正在努力升级 Dockerfile 中的 PHP 版本。我在 Dockerfile 中看到过一些使用

FROM php:8.1-fpm
的示例。然而,由于我已经在使用
FROM myoung34/github-runner:latest
,我不确定如何组合这些。

任何帮助或指导将不胜感激。

docker dockerfile apt
1个回答
0
投票

我通过使用包

ppa:ondrej/php
解决了这个问题。 对于那些面临同样问题的人,我的 Dockerfile 现在看起来像这样:

# base
FROM myoung34/github-runner:latest

# Let's create a nice FAT image with all bells & whistles
RUN add-apt-repository -y ppa:ondrej/php && \
    add-apt-repository -y ppa:apt-fast/stable && \
    curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
    apt-key adv --fetch-keys https://dl.yarnpkg.com/debian/pubkey.gpg && \
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list \
    && \
    apt-get update \
    && \
    apt install -y --no-install-recommends \
    vim \
    apt-utils \
    apt-fast \
    rsync \
    gcc \
    g++ \
    make \
    dh-autoreconf \
    zip \
    php8.1-cli \
    php8.1-curl \
    php8.1-xml \
    php8.1-zip \
    php8.1-mbstring \
    php8.1-bcmath \
    php8.1-intl \
    python \
    unzip \
    nodejs \
    yarn \
    phantomjs \
    && \
    apt clean \
    && \
    npm i -g gulp \
    && \
    mkdir -p /actions-runner/installers

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer

WORKDIR /actions-runner

COPY ./installers /actions-runner/installers
COPY ./ssh /actions-runner/ssh

RUN chmod +x /actions-runner/installers/ssh-keys.sh \
  && chmod +x /actions-runner/installers/google-chrome.sh \
  && /actions-runner/installers/ssh-keys.sh \
  && /actions-runner/installers/google-chrome.sh \
  && rm -rf /actions-runner/installers \
  && rm -rf /actions-runner/ssh \ 
  && rm -rf /var/lib/apt/lists/* \
  && rm -rf /tmp/*

ENV QT_QPA_PLATFORM=offscreen
RUN echo 'alias gsed="sed"' >> ~/.bashrc
RUN echo -e '#!/bin/bash\nsed "$@"' > /usr/bin/gsed && \
    chmod +x /usr/bin/gsed

通过

ppa:ondrej/php
,我可以访问最新的 PHP 版本。在
RUN
命令中,我可以指定要使用的 PHP 版本,正如您在我的代码中看到的那样。

© www.soinside.com 2019 - 2024. All rights reserved.