The service I'm using gives you a command to create a docker-compose file. You can then run docker-compose up and choose to create a new database.
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.8
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
# managementApiSecret: my-secret
databases:
default:
connector: mysql
host: mysql
port: 3306
user: root
password: prisma
migrations: true
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: prisma
volumes:
- mysql:/var/lib/mysql
volumes:
mysql:
This worked but now I need to set a second project with a new database. Even though I chose the option to set up a new database when I run my project I can see it's connecting to my old one:
prisma init
? Set up a new Prisma server or deploy to an existing server? Create new database
? What kind of database do you want to deploy to? MySQL
Created 3 new files:
prisma.yml Prisma service definition
datamodel.graphql GraphQL SDL-based datamodel (foundation for database)
docker-compose.yml Docker configuration file
Next steps:
1. Start your Prisma server: docker-compose up -d
2. Deploy your Prisma service: prisma deploy
3. Read more about Prisma server:
Is there something in my docker-compose.yml thats wrong? I belive default is the database name so I've tried the following but the same thing happens:
databases:
default2:
connector: mysql
Related
I have used docker-compose.yaml. I have configured in docker-compose.yml bellow like:
Step 1: In docker-compose.yaml I user bellow code
services:
postgres:
image: postgres
container_name: postgres
hostname: postgres
volumes:
- db-data:/var/lib/postgresql/data
restart: always
ports:
- 5432:5432
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: accountdb
account-opening:
image: ehaque95/pocv1-account-opening:0.0.1-SNAPSHOT
mem_limit: 700m
ports:
- "8081:8081"
networks:
- account-network
depends_on:
- postgres
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/accountdb
volumes:
db-data:
Step 2 :
I have configure applicaiton.yml in spring boot bellow like:
spring:
datasource:
url: jdbc:postgresql://postgres:5432/accountdb
username: postgres
password: postgres
jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect
database: postgresql
hibernate:
ddl-auto: update
properties:
dialect: org.hibernate.dialect.PostgreSQLDialect
Note : postgresql server IP change frequently. When i run docker inpspect ,it shows some "IPAddress": "172.19.0.2" or sometimes "IPAddress": "172.19.0.3".It shows when I run docker-compose up again.
It shows connection error.what is the wrong of my code connect to postgresql. Please help me
For two containers to communicate with each other, they must be on the same Docker network. By default, Compose creates a network named default and attaches containers to it; if you specify other networks: for a container, then they are not attached to the default network.
In your docker-compose.yml, the account-opening container has a networks: block, but postgres doesn't:
version: '3.8'
services:
postgres:
...
# no networks:, so implicitly
# networks: [default]
account-opening:
...
networks: [account-network] # and not default
# The postgres container is on the default network
# This container is on account-network
# And so this host name doesn't resolve
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/accountdb
There's nothing wrong with using the default network. For most typical applications you can delete all of the networks: blocks in the entire file. Then the default network will get created with default settings, and all of the containers will attach to that network, and be able to address each other by their Compose service name.
try
url: jdbc:postgresql://localhost:5432/accountopendb
if you are running both the spring app and the postgresql container in the same machine in your datasource config.
First of all we have a MySQL DB setup on Heroku that already has data on it. I'm trying to add the Prisma layer on top of our DB.
My docker-compose.yml:
version: "3"
services:
prisma:
image: prismagraphql/prisma:1.34
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
# managementApiSecret: my-secret
databases:
default:
connector: mysql
host:
database:
user: user
password:
rawAccess: true
port: '3306'
migrations: false
Prisma.yml
# The HTTP endpoint for Prisma API
endpoint: http://localhost:4466
# Points to the file that contains your datamodel
datamodel: datamodel.prisma
# Specifies language and location for the generated Prisma Client
generate:
- generator: javascript-client
output: ./generated/prisma-client/
I go through prisma init and it connects to the DB and sets up the datamodel as it should, from what it seems like.
After docker-compose up -d I run prisma deploy and it hits me with
Could not connect to server at http://localhost:4466. Please check if
your server is running.
I run systemctl status docker and the docker is running as it should.
I then run docker-compose logs and I get back this
Exception in thread "main" java.sql.SQLSyntaxErrorException:
(conn=10044859) Access denied for user 'user'#'%' to database 'prisma'
So from reading around does prisma need the DB user to have the privileges to create a new schema in the DB for its management purposes?
I have no clue where to go from here. If I'm doing something wrong here, the help would be much appreciated!
Btw: SSL is not active on the DB so there is no need for it to be true.
I'm getting the following crash when using docker-compose with Vapor & FluentMySQL.
api_1 | [ INFO ] Migrating 'mysql' database (/app/.build/checkouts/fluent/Sources/Fluent/Migration/MigrationConfig.swift:69)
api_1 | Fatal error: Error raised at top level: NIO.ChannelError.connectFailed(NIO.NIOConnectionError(host: "db", port: 3309, dnsAError: nil, dnsAAAAError: nil, connectionErrors: [NIO.SingleConnectionFailure(target: [IPv4]db/172.27.0.2:3309, error: connection reset (error set): Connection refused (errno: 111))])): file /home/buildnode/jenkins/workspace/oss-swift-5.1-package-linux-ubuntu-18_04/swift/stdlib/public/core/ErrorType.swift, line 200
Migration fails when using:
migrations.add(model: Model.self, database: .mysql)
If I remove that so no Models are migrated the app builds without errors and I am able to access it at http://localhost/.
My docker-compose.yml looks like this:
version: "3.7"
services:
api:
image: vaporapiimage
ports:
- 80:8080
environment:
MYSQL_HOST: db
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: dbname
SLEEP_LENGTH: 7
MYSQL_PORT: 3309
depends_on:
- db
db:
image: mysql:8.0.1
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: dbname
MYSQL_USER: user
MYSQL_PASSWORD: password
ports:
- "3309:3306"
It builds and runs as expected locally from Xcode (as in without Docker).
If the api service is commented out then the db service will run on its own and create the database on first run.
Any help would be greatly appreciated.
UPDATE:
Replacing the api with Adminer results in being able to access the db through Adminer in the browser. So the db service is accessible and it seems as if the issue is with Vapor/Fluent (or rather my use of them):
admin:
image: adminer
ports:
- 8080:8080
The problem was that I had mapped the port for db to 3309 so that it didn't conflict with the host MYSQL but had also set the ENV 'MYSQL_PORT' to 3309 when that should have been kept as the default 3306 because that was for communication between containers.
I want to create a project using Prisma and i want to connect it to my local Mongodb database but i cant find the connection string it should be like this : http://user1:myPassword#localhost:27017/admin
If anyone knows how can i find my user and password.
You have to create the user in your mongodb server.
If you are using Prisma CLI, you can configure your database connection in the file docker-compose.yml,
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.34
restart: always
ports:
- '4466:4466'
environment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: mongo
uri: mongodb://http://user1:myPassword#localhost:27017/admin
database: mydb
Check this link for more info
I've got Prisma connected to my MongoDB but when I make any mutations, a new database is being created in MongoDB called default_default and data is being added there instead of the database I specified when going through the setup here
https://www.prisma.io/docs/get-started/01-setting-up-prisma-existing-database-JAVASCRIPT-a003/
I'd expect the data to be saved in the database specified in the docker-compose.yml file
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.23
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
# managementApiSecret: my-secret
databases:
default:
connector: mongo
uri: 'mongodb://host.docker.internal:27017/my-db-name'
Has anyone experienced something similar and found a solution?
Thanks
This you do in prisma.config by setting endpoint:
endpoint: http://localhost:4466/graphql/default
This will use database graphq_default