Hello cool devs, how can I deploy prisma locally
# orm-help
c
Hello cool devs, how can I deploy prisma locally
k
Have docker installed on your machine. If you're already working in the cloud you'll want to install prisma globally and then run
prisma init
on an empty directory (select "Create new Database" and MySQL), that should give you a file called docker-compose.yml that looks like this:
Copy code
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:
A good place to put that file in your server project is under the directory
./database
if that's what you've got. Make sure you have a .env file that looks something like this:
Copy code
PRISMA_STAGE="dev"
PRISMA_ENDPOINT="<http://self:4466/server/dev>"
PRISMA_CLUSTER="local"
PRISMA_SECRET="SOME_PRISMA_SECRET"
APP_SECRET="SOME_APP_SECRET"
PRISMA_MANAGEMENT_API_SECRET="SOME_PRISMA_MANAGEMENT_API_SECRET"
Then bring the server up with
docker-compose -f ./database/docker-compose.yml up -d
(-f names the file, up brings it "up", and -d puts it in the background). Actually perhaps take a look at my personal project's Readme, I basically wrote notes to myself on .env: https://github.com/TiE23/metric-teacher/tree/master/server
The docker-compose file is a configuration file that downloads the prisma and mysql software in docker containers and quickly launches them up with some basic settings such as ports and default passwords. Take a look at what's running with
docker ps
and from there you can shell into the mysql container with this:
docker exec -it database_db_1 mysql -u root --host localhost --port 4466 --password=prisma -D server@dev
(
database_db_1
is the container name, it might be different for you.
server@dev
is the project name and stage, it might be different for you)
c
Thanks a lot 🙏