Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_password_here
POSTGRES_DB=playmoney

NEXT_PUBLIC_WEB_URL="http://localhost:3000"
NEXT_PUBLIC_API_URL="http://localhost:3001"

POSTGRES_PRISMA_URL="postgresql://postgres:password@localhost:5432/playmoney?schema=public"
POSTGRES_URL_NON_POOLING="postgresql://postgres:password@localhost:5432/playmoney?schema=public"
POSTGRES_PRISMA_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?schema=public"
POSTGRES_URL_NON_POOLING="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?schema=public"

NEXTAUTH_URL="http://localhost:3000"
# See: https://next-auth.js.org/configuration/options#nextauth_secret
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:20

WORKDIR /app

RUN apt-get update && apt-get install -y postgresql-client

COPY . .

RUN npm install
RUN npm install -g prisma cross-env storybook

RUN npx prisma generate
RUN npx storybook init

EXPOSE 3000 3001 5555 6006
ENTRYPOINT ["./docker-entrypoint.sh"]
35 changes: 35 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000" # Web app
- "3001:3001" # Backend server
- "5555:5555" # Database viewer
- "6006:6006" # Storybook
depends_on:
- db
environment:
- NODE_ENV=development # TODO: allow this to be set in .env & changed?
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
- POSTGRES_HOST=db
volumes:
- .:/app
- /app/node_modules

db:
image: postgres:16
ports:
- "5432:5432"
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
- postgres_data:/var/lib/postgresql/data

volumes:
postgres_data:
20 changes: 20 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -xe

function wait_for_db() {
until pg_isready -h $POSTGRES_HOST -p 5432; do
echo "Waiting for the database to be accessible..."
sleep 2
done
}

wait_for_db

npx prisma migrate dev

# ignore failures below, probably best to remove this once
# it's clear why HOUSE user isn't being populated by default
npx prisma db seed || true

npm run dev