Composer could not find a composer.json file in /app and Npm WARN saveError ENOENT: no such file or directory, open '/app/package.json'

Viewed 139

I have my project on github https://github.com/Daniil1996-vrn/DEVJuniorPHP. This is docker-compose.yml:

version: "3.7"

networks:
  laravel:

volumes:
  database:

services:
  database:
    image: postgres:10
    container_name: postgres
    restart: "no"
    volumes:
      - .:/var/lib/postgresql/data
    networks:
      - laravel
    ports:
      - 5432:5432
    environment:
      
      POSTGRES_USER: "postgres"
      POSTGRES_PASSWORD: "admin1234"
      POSTGRES_DB: "DEVJuniorPHP"

  composer:
    image: composer:latest
    container_name: composer
    volumes:
      - ./:/app
    working_dir: /app
    command: composer install

  node:
    image: node:12
    container_name: node
    volumes:
      - ./:/app
    working_dir: /app
    command: npm install

  app:
    container_name: app
    restart: "no"
    volumes:
      - ./app
      
    networks:
      - laravel
    depends_on:
      - composer
      - node
    build:
      context: .
      dockerfile: ./docker/app/dockerfile
    
    command: php-fpm

  webserver:
    image: nginx:stable
    container_name: webserver
    restart: "no"
    volumes:
      - ./app
      - ./nginx/default.conf:/etc/nginx/conf.d 
    networks:
      - laravel
    ports:
      - 8000:8000
    depends_on:
      - database
      - app

DockerFile:

FROM php:8.1.4-fpm-alpine3.14

# Update package manager ready for deps to be installed
RUN apk update

COPY package.json .
#RUN npm install
COPY . .

# Set the working directory of the container to the hosted directory
WORKDIR /app

nginx.conf:

server {
    listen 8000;
    index index.php index.html;
    server_name localhost;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/public;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
        gzip_static on;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;

        # Uncomment to extend nginx's max timeout to 1 hour
        # fastcgi_read_timeout 3600;
    }
}

But when I run command docker-compose up I get the next error in my terminal:

Composer could not find a composer.json file in /app
npm no such file or directory, open '/app/package.json'

And i cannot open localhost:8000 or 192.168.99.100

0 Answers
Related