简体   繁体   English

如何在 PHP docker 映像(symfony 4 项目)上安装纱线和 npm

[英]How to install yarn and npm on a PHP docker image (symfony 4 project)

Im working on a symfony 4/posgresql project.我正在从事 symfony 4/posgresql 项目。 Im using docker toolbox.我正在使用 docker 工具箱。

I need to install webpack encore bundle on symfony, but in order to do this, i need to add yarn and npm to my project.我需要在 symfony 上安装 webpack 安可包,但为了做到这一点,我需要将纱线和 npm 添加到我的项目中。 Somebody told me i should add theses 2 installations on my php docker container, but i don't know which command to add (im a linux/docker beginner).有人告诉我应该在我的 php docker 容器上添加这些 2 安装,但我不知道要添加哪个命令(我是 linux/docker 初学者)。

This is my docker-compose.yaml:这是我的 docker-compose.yaml:

 
services:
  database:
    image: postgres:11-alpine
    ports:
        - "5432:5432"
    volumes:
      - 'boeki_database:/var/lib/postgresql/data'
    environment:
      POSTGRES_PASSWORD: root
 
  database_pg_admin:
    image: dpage/pgadmin4
    ports:
        - "8001:80"
    environment:
      PGADMIN_DEFAULT_EMAIL: root@root.com
      PGADMIN_DEFAULT_PASSWORD: root
       
  application:
    build:
      context: .
      dockerfile: ./docker/Dockerfile
    working_dir: /var/www/project
    ports:
        - "8000:80"
    volumes:
      - ./:/var/www/project:rw,cached
      - ./docker/http/000-default.conf:/etc/apache2/sites-enabled/000-default.conf:rw,cached
 
volumes:
  boeki_database: {} 

And this is my Dockerfile:这是我的 Dockerfile:

 
RUN apt-get update && \
    apt-get install -y libpq-dev g++ zlib1g-dev libicu-dev vim git zip
 
#GD
RUN apt-get update && \
  DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
  libfreetype6-dev \
  libjpeg62-turbo-dev \
  libpng-dev \
  libzip-dev \
  poppler-utils
 
RUN rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \
  docker-php-ext-install -j "$(nproc)" gd pdo_pgsql
 
RUN docker-php-ext-configure intl
RUN docker-php-ext-install pdo pdo_mysql intl zip opcache
 
RUN pecl install redis && echo "extension=redis.so" > /usr/local/etc/php/conf.d/docker-php-ext-redis.ini
 
RUN a2enmod rewrite
 
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

Thanks for the help !谢谢您的帮助 !

according to https://classic.yarnpkg.com/en/docs/install#debian-stable which provides some commands to follow, adding the following to your dockerfile should work (disclaimer: I'm not extremely familiar with docker)根据https://classic.yarnpkg.com/en/docs/install#debian-stable它提供了一些要遵循的命令,将以下内容添加到您的 dockerfile应该可以工作(免责声明:我对 docker 不是很熟悉)

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && sudo apt-get install -y yarn

(the -y removes the questions) ( -y 删除问题)

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

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