Hello. I dont really find out, how i deploy my exp...
# orm-help
p
Hello. I dont really find out, how i deploy my express prisma app on Docker, that prisma create the Database tables on first run. Anyone have an idea? Thats my dockerfile:
FROM node:latest
# Create app directory WORKDIR
/usr/src/app
COPY _package.json_
./
COPY _pnpm-lock.yaml_
./
RUN _npm_
install
-g
pnpm
RUN _pnpm_
install
RUN _pnpm_
install
-g
prisma
COPY _._
.
EXPOSE
8000
RUN _pnpx_
prisma
generate
CMD _[_ "npm"_,_ "run"_,_ "start:prod" _]_
r
@Philipp Minder 👋 To create database tables on the first run, on another database, you can use
prisma migrate deploy
as you already have the migrations in place.
p
thanks for your answer. i tried to integrate that in my Dockerfile:
EXPOSE _8000_
RUN _pnpx_
prisma
migrate
deploy
RUN _pnpx_
prisma
generate
Unfortnatly i got the following Error:
> [pfaditoolbox_backend  9/10] RUN pnpx prisma migrate deploy:
#22 0.830 Environment variables loaded from .env
#22 1.300 Prisma schema loaded from prisma/schema.prisma
#22 1.326 Datasource "db": MySQL database "pfaditoolbox" at "localhost:3306"
#22 1.366
`#22 1.366 Error: P1001: Can't reach database server at `localhost`:`3306``
#22 1.366
`#22 1.366 Please make sure your database server is running at `localhost`:`3306`.
Copy code
------`
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c pnpx prisma migrate deploy]: exit code: 1
My Docker-Compose File looks the following:
# Set the version of docker compose to use
version: '3.9'
# The containers that compose the project
services:
 
db:
   
image: mariadb
   
environment:
     
MARIADB_ROOT_PASSWORD: "password"
     
MARIADB_DATABASE: "pfaditoolbox"
   
ports:
     
- '3306:3306'
 
backend:
   
build: ./backend
   
depends_on:
     
- db
   
ports:
     
- '8000:8000'
   
environment:
     
DATABASE_URL: "<mysql://root:password@db:3306/pfaditoolbox>"
     
CORS_URL: "localhost:8000"
 
frontend:
   
build: ./frontend
   
depends_on:
     
- db
   
ports:
     
- '3000:3000'
May you have any suggestions?
r
You won’t be able to access it using
localhost
as you’re running it inside the container. You need to use
db
instead of
localhost
p
yea i've got the same error with db. im also curious why the docker env varbiale are not loading. May i have to dive in docker docs.