почему не выполняется код после выполняния entrypoint.sh nestjs prisma postgresql
у меня Nest JS приложение которое взаимодейтсвует с базой данных PostgreSQL
и почему то в Dockerfile после файла запуска entrypoint.sh (этот файл я использую для выполнения инициализции и миграции prism'ы в бд ) выполнение Dockerfil'а не идет.
вот мой Docker-compose файл
version: '3.5'
services:
db:
image: postgres
restart: always
env_file:
- .env
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
- POSTGRES_DB=postgres
- POSTGRES_HOST=db
container_name: postgres
ports:
- '5432:5432'
app:
image: node
build:
context: .
dockerfile: Dockerfile
container_name: nest-docker-postgres
entrypoint: ["./entrypoint.sh"]
environment:
- PORT=${PORT}
ports:
- '3000:3000'
depends_on:
- db
Вот мой Dockerfile
FROM node:20
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install NestJS dependencies
RUN npm install
# Copy the rest of the application code to the working directory
COPY . .
# Make the entrypoint script executable
RUN chmod +x ./entrypoint.sh
# Set the entrypoint and default command
ENTRYPOINT ["./entrypoint.sh"]
CMD ["npm", "run", "start:prod"]
а вот мой entrypoint.sh
#!/bin/bash
npx prisma generate
npx prisma migrate dev
exec "$@"
Сижу уже неделю)) Миграции и инициализация успешно выполняется Вот логи
=> [app internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 811B 0.0s
=> [app internal] load metadata for docker.io/library/node:20 2.5s
=> [app internal] load .dockerignore 0.0s
=> => transferring context: 100B 0.0s
=> [app 1/6] FROM docker.io/library/node:20@sha256:3b676479124ebdb0348f540e5c8b64f959ec1358cea05080b711d965f5353a34 0.0s
=> [app internal] load build context 0.0s
=> => transferring context: 6.62kB 0.0s
=> CACHED [app 2/6] WORKDIR /app 0.0s
=> CACHED [app 3/6] COPY package*.json ./ 0.0s
=> CACHED [app 4/6] RUN npm install 0.0s
=> CACHED [app 5/6] COPY . . 0.0s
=> CACHED [app 6/6] RUN chmod +x ./entrypoint.sh 0.0s
=> [app] exporting to image 0.1s
=> => exporting layers 0.0s
=> => writing image sha256:da3243300b2333fc58828fa8eabbb787db8d017cf2896d384d2476fa5b5cda8c 0.1s
=> => naming to docker.io/library/node 0.0s
[+] Running 3/2
✔ Network dremin-s-recipes-backend-_default Created 0.0s
✔ Container postgres Created 33.1s
✔ Container nest-docker-postgres Created 0.1s
Attaching to nest-docker-postgres, postgres
postgres | The files belonging to this database system will be owned by user "postgres".
postgres | This user must also own the server process.
postgres |
postgres | The database cluster will be initialized with locale "en_US.utf8".
postgres | The default database encoding has accordingly been set to "UTF8".
postgres | The default text search configuration will be set to "english".
postgres |
postgres | Data page checksums are disabled.
postgres |
postgres | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgres | creating subdirectories ... ok
postgres | selecting dynamic shared memory implementation ... posix
postgres | selecting default max_connections ... 100
postgres | selecting default shared_buffers ... 128MB
postgres | selecting default time zone ... Etc/UTC
postgres | creating configuration files ... ok
postgres | running bootstrap script ... ok
postgres | performing post-bootstrap initialization ... ok
nest-docker-postgres | Environment variables loaded from .env
nest-docker-postgres | Prisma schema loaded from prisma/schema.prisma
nest-docker-postgres |
nest-docker-postgres | ✔ Generated Prisma Client (v5.10.2) to ./node_modules/@prisma/client in 102ms
nest-docker-postgres |
nest-docker-postgres | Start using Prisma Client in Node.js (See: https://pris.ly/d/client)
nest-docker-postgres | ```
nest-docker-postgres | import { PrismaClient } from '@prisma/client'
nest-docker-postgres | const prisma = new PrismaClient()
nest-docker-postgres | ```
nest-docker-postgres | or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate)
nest-docker-postgres | ```
nest-docker-postgres | import { PrismaClient } from '@prisma/client/edge'
nest-docker-postgres | const prisma = new PrismaClient()
nest-docker-postgres | ```
nest-docker-postgres |
nest-docker-postgres | See other ways of importing Prisma Client: http://pris.ly/d/importing-client
nest-docker-postgres |
nest-docker-postgres | ┌─────────────────────────────────────────────────────────────┐
nest-docker-postgres | │ Deploying your app to serverless or edge functions? │
nest-docker-postgres | │ Try Prisma Accelerate for connection pooling and caching. │
nest-docker-postgres | │ https://pris.ly/cli/accelerate │
nest-docker-postgres | └─────────────────────────────────────────────────────────────┘
nest-docker-postgres |
postgres | syncing data to disk ... ok
postgres |
postgres |
postgres | Success. You can now start the database server using:
postgres |
postgres | pg_ctl -D /var/lib/postgresql/data -l logfile start
postgres |
postgres | initdb: warning: enabling "trust" authentication for local connections
postgres | initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
postgres | waiting for server to start....2024-04-11 11:01:42.073 UTC [48] LOG: starting PostgreSQL 16.2 (Debian 16.2-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
postgres | 2024-04-11 11:01:42.079 UTC [48] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres | 2024-04-11 11:01:42.094 UTC [51] LOG: database system was shut down at 2024-04-11 11:01:39 UTC
postgres | 2024-04-11 11:01:42.101 UTC [48] LOG: database system is ready to accept connections
postgres | done
postgres | server started
postgres |
postgres | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
postgres |
postgres | waiting for server to shut down...2024-04-11 11:01:42.187 UTC [48] LOG: received fast shutdown request
postgres | .2024-04-11 11:01:42.194 UTC [48] LOG: aborting any active transactions
postgres | 2024-04-11 11:01:42.195 UTC [48] LOG: background worker "logical replication launcher" (PID 54) exited with exit code 1
postgres | 2024-04-11 11:01:42.196 UTC [49] LOG: shutting down
postgres | 2024-04-11 11:01:42.201 UTC [49] LOG: checkpoint starting: shutdown immediate
postgres | 2024-04-11 11:01:42.228 UTC [49] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.009 s, sync=0.007 s, total=0.033 s; sync files=2, longest=0.004 s, average=0.004 s; distance=0 kB, estimate=0 kB; lsn=0/14EAA70, redo lsn=0/14EAA70
postgres | 2024-04-11 11:01:42.232 UTC [48] LOG: database system is shut down
postgres | done
postgres | server stopped
postgres |
postgres | PostgreSQL init process complete; ready for start up.
postgres |
postgres | 2024-04-11 11:01:42.310 UTC [1] LOG: starting PostgreSQL 16.2 (Debian 16.2-1.pgdg120+2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
postgres | 2024-04-11 11:01:42.311 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres | 2024-04-11 11:01:42.311 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres | 2024-04-11 11:01:42.319 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres | 2024-04-11 11:01:42.327 UTC [62] LOG: database system was shut down at 2024-04-11 11:01:42 UTC
postgres | 2024-04-11 11:01:42.334 UTC [1] LOG: database system is ready to accept connections
nest-docker-postgres | Environment variables loaded from .env
nest-docker-postgres | Prisma schema loaded from prisma/schema.prisma
nest-docker-postgres | Datasource "db": PostgreSQL database "postgres", schema "public" at "db:5432"
nest-docker-postgres |
postgres | 2024-04-11 11:01:42.457 UTC [67] ERROR: relation "_prisma_migrations" does not exist at character 126
postgres | 2024-04-11 11:01:42.457 UTC [67] STATEMENT: SELECT "id", "checksum", "finished_at", "migration_name", "logs", "rolled_back_at", "started_at", "applied_steps_count" FROM "_prisma_migrations" ORDER BY "started_at" ASC
postgres | 2024-04-11 11:01:42.692 UTC [68] FATAL: terminating connection due to administrator command
postgres | 2024-04-11 11:01:42.798 UTC [60] LOG: checkpoint starting: immediate force wait
postgres | 2024-04-11 11:01:42.852 UTC [60] LOG: checkpoint complete: wrote 6 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.015 s, sync=0.013 s, total=0.055 s; sync files=5, longest=0.007 s, average=0.003 s; distance=4257 kB, estimate=4257 kB; lsn=0/1913240, redo lsn=0/1913208
postgres | 2024-04-11 11:01:43.306 UTC [69] FATAL: terminating connection due to administrator command
postgres | 2024-04-11 11:01:43.437 UTC [60] LOG: checkpoint starting: immediate force wait
postgres | 2024-04-11 11:01:43.533 UTC [60] LOG: checkpoint complete: wrote 4 buffers (0.0%); 1 WAL file(s) added, 0 removed, 0 recycled; write=0.004 s, sync=0.004 s, total=0.096 s; sync files=4, longest=0.002 s, average=0.001 s; distance=4503 kB, estimate=4503 kB; lsn=0/1D78E78, redo lsn=0/1D78E40
nest-docker-postgres | Applying migration `20240302093845_init`
nest-docker-postgres | Applying migration `20240302104810_init`
nest-docker-postgres | Applying migration `20240302110918_init`
nest-docker-postgres | Applying migration `20240302111059_init`
nest-docker-postgres | Applying migration `20240303121629_`
nest-docker-postgres | Applying migration `20240303130206_`
nest-docker-postgres | Applying migration `20240303143722_`
nest-docker-postgres | Applying migration `20240303162844_aaaa`
nest-docker-postgres | Applying migration `20240309100235_`
nest-docker-postgres | Applying migration `20240312174244_`
nest-docker-postgres |
nest-docker-postgres | The following migration(s) have been applied:
nest-docker-postgres |
nest-docker-postgres | migrations/
nest-docker-postgres | └─ 20240302093845_init/
nest-docker-postgres | └─ migration.sql
nest-docker-postgres | └─ 20240302104810_init/
nest-docker-postgres | └─ migration.sql
nest-docker-postgres | └─ 20240302110918_init/
nest-docker-postgres | └─ migration.sql
nest-docker-postgres | └─ 20240302111059_init/
nest-docker-postgres | └─ migration.sql
nest-docker-postgres | └─ 20240303121629_/
nest-docker-postgres | └─ migration.sql
nest-docker-postgres | └─ 20240303130206_/
nest-docker-postgres | └─ migration.sql
nest-docker-postgres | └─ 20240303143722_/
nest-docker-postgres | └─ migration.sql
nest-docker-postgres | └─ 20240303162844_aaaa/
nest-docker-postgres | └─ migration.sql
nest-docker-postgres | └─ 20240309100235_/
nest-docker-postgres | └─ migration.sql
nest-docker-postgres | └─ 20240312174244_/
nest-docker-postgres | └─ migration.sql
postgres | 2024-04-11 11:01:44.051 UTC [70] FATAL: terminating connection due to administrator command
postgres | 2024-04-11 11:01:44.153 UTC [60] LOG: checkpoint starting: immediate force wait
postgres | 2024-04-11 11:01:44.215 UTC [60] LOG: checkpoint complete: wrote 108 buffers (0.7%); 0 WAL file(s) added, 0 removed, 1 recycled; write=0.005 s, sync=0.044 s, total=0.063 s; sync files=103, longest=0.0=103, longest=0.013 s, average=0.001 s; distance=4959 kB, estimate=4959 kB; lsn=0/2250CF8, redo lsn=0/2250CC0
postgres | 2024-04-11 11:06:44.212 UTC [60] LOG: checkpoint starting: time
postgres | 2024-04-11 11:06:48.949 UTC [60] LOG: checkpoint complete: wrote 48 buffers (0.3%); 0 WAL file(s) added, 0 removed, 0 recycled; write=4.718 s, sync=0.008 s, total=4.737 s; sync files=13, longest=0.004 s, average=0.001 s; distance=276 kB, estimate=4491 kB; lsn=0/2295DD0, redo lsn=0/2295D98
````