From 8f1bf7139efac34a9613d2b147edca44a85e27ee Mon Sep 17 00:00:00 2001 From: laksith19 Date: Thu, 3 Nov 2022 15:30:15 -0700 Subject: [PATCH] Better dx (#29) Use Docker for local DB --- .env.example | 6 +++--- README.md | 17 ++++++++++++++++- docker-compose.yaml | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 docker-compose.yaml diff --git a/.env.example b/.env.example index 2bb4d49..a2b20e9 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ # This is an example of what the .env should look like -# Database -DATABASE_URL='' +# Database - Replace for production +DATABASE_URL='mysql://root:prisma@localhost:3306/sohq' NEXT_PUBLIC_HOSTNAME='http://localhost:3000' @@ -13,4 +13,4 @@ NEXTAUTH_URL='http://localhost:3000' # Ably ABLY_SERVER_API_KEY='' -NEXT_PUBLIC_ABLY_CLIENT_API_KEY='' \ No newline at end of file +NEXT_PUBLIC_ABLY_CLIENT_API_KEY='' diff --git a/README.md b/README.md index c0f0561..908838f 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,22 @@ Google OAuth is used for authentication.
Database -SOHQ uses MySQL as its database, mainly because the free tier of Planetscale is very nice. For local development, I am currently looking into possibly using Docker to have a local MySQL instance. +#### Local Development +For local development we run a docker container serving a mySQL database. + +1. Install [Docker](https://docs.docker.com/get-docker/) on your machine. + +2. Start the container by running: +``` +docker compose up +``` + + +#### Production + + + +For the production environment, the free tier of Planetscale is very nice. 1. Create a new database on Planetscale. diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..d35e005 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,18 @@ +version: '3' +services: + mysql-db: + image: mysql:5.7 + restart: always + ports: + - '3306:3306' + ulimits: + nofile: + soft: 65536 + hard: 65536 + environment: + MYSQL_ROOT_PASSWORD: prisma + volumes: + - mysql:/var/lib/mysql +volumes: + mysql: ~ +