Halo Saya tidak tahu di mana saya salah ketika mencoba menggunakan docker compose dengan postgress

Docker menulis yml:

version: "3.7"
services:
  db:
    image: postgres
    environment:
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
      POSTGRES_DB: emasa
    volumes:
      - ./pgdata:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    web:
      image: emasapg
      depends_on:
        - dbs
      ports:
        - "4000:4000"

File buruh pelabuhan

FROM node as builder
WORKDIR usr/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build


FROM node
WORKDIR usr/app
COPY package*.json ./
RUN npm install --production

COPY --from=builder /usr/app/dist ./dist

COPY ormconfig.docker.json ./ormconfig.json
COPY .env . 

expose 4000
CMD node dist/src/index.js

Paket saya.json:

{
  "name": "back-end",
  "version": "0.0.1",
  "description": "Awesome project developed with TypeORM.",
  "devDependencies": {
    "@types/express": "^4.17.3",
    "@types/graphql": "^14.5.0",
    "@types/node": "^13.9.1",
    "ts-node": "8.6.2",
    "typescript": "3.3.3333"
  },
  "dependencies": {
    "apollo-server-express": "^2.11.0",
    "express": "^4.17.1",
    "graphql": "^14.6.0",
    "pg": "^7.3.0",
    "reflect-metadata": "^0.1.13",
    "typeorm": "0.2.24"
  },
  "scripts": {
    "start": "ts-node src/index.ts"
  }
}

Berbuat salah:

npm ERR! skrip yang hilang: build

Struktur file saya:

enter image description here

Kesalahan dimulai pada baris ini:

baris 6: RUN npm run build

Edit: lupa menambahkan package.json ke pertanyaan

0
user12356906 17 Maret 2020, 21:18

1 menjawab

Jawaban Terbaik

Ini pada dasarnya mengeluh tentang kehilangan skrip build, ia mencoba menjalankannya, tetapi tidak ada di package.json Anda!

Saya pikir Anda harus mencoba memperbarui file package.json Anda dan menambahkan skrip build:

{
  "name": "back-end",
  "version": "0.0.1",
  "description": "Awesome project developed with TypeORM.",
  "devDependencies": {
    "@types/express": "^4.17.3",
    "@types/graphql": "^14.5.0",
    "@types/node": "^13.9.1",
    "ts-node": "8.6.2",
    "typescript": "3.3.3333"
  },
  "dependencies": {
    "apollo-server-express": "^2.11.0",
    "express": "^4.17.1",
    "graphql": "^14.6.0",
    "pg": "^7.3.0",
    "reflect-metadata": "^0.1.13",
    "typeorm": "0.2.24"
  },
  "scripts": {
    "start": "ts-node src/index.ts",
    "build": ""  // your build script goes here, "tsc" should be fine
  }
}
2
WaLid LamRaoui 17 Maret 2020, 18:53