我已经将我的 Laravel 项目容器化了。但是,我希望能够在 Web 容器(nginx:1.25 容器)上运行纱线命令。我已经在互联网上搜索过,但没有成功找到答案。
这是我的 Dockerfile
FROM nginx:1.25
# Copy the Nginx configuration file
COPY ./default.conf /etc/nginx/conf.d/default.conf
# Add yarn here
# Set the working directory
WORKDIR /src
它与您使用的基础镜像不同,对于您的情况,nginx:1.25基于debian bookworm,所以我建议使用nvm和npm安装yarn:
FROM nginx:1.25
# Copy the Nginx configuration file
COPY ./default.conf /etc/nginx/conf.d/default.conf
# Add yarn here
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
RUN source ~/.bashrc
RUN nvm install --lts
RUN npm install -g yarn
# Set the working directory
WORKDIR /src