From b721589fe717f0765863b41d9b1d1c1171415816 Mon Sep 17 00:00:00 2001
From: JohanHjelsethStorstad
<82723971+JohanHjelsethStorstad@users.noreply.github.com>
Date: Thu, 19 Oct 2023 18:12:22 +0200
Subject: [PATCH 04/13] refactor: add stages to Dockerfile for prod and dev.
Prisma now generates correctly in both prod and dev
---
Dockerfile | 28 +++++++++++++++-----
Dockerfile.dev | 9 -------
docker-compose.dev.yml | 3 ++-
docker-compose.yml | 5 ++++
package.json | 3 +--
scripts/start.dev.sh | 3 ---
scripts/start.sh | 3 ---
src/app/components/Loader/Loader.js | 13 +++++++++
src/app/components/Loader/Loader.module.scss | 5 ++++
9 files changed, 47 insertions(+), 25 deletions(-)
delete mode 100644 Dockerfile.dev
delete mode 100644 scripts/start.dev.sh
delete mode 100644 scripts/start.sh
create mode 100644 src/app/components/Loader/Loader.js
create mode 100644 src/app/components/Loader/Loader.module.scss
diff --git a/Dockerfile b/Dockerfile
index 86df5d074..7dabfa75c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,12 +1,26 @@
-FROM node:18-alpine
-
+FROM node:18-alpine AS base
WORKDIR /usr/src/app
-
-# Install node modules
COPY package*.json ./
RUN npm ci
+COPY . .
+############################################################
+FROM node:18-alpine AS prod
+WORKDIR /usr/src/app
+COPY --from=base /usr/src/app/ .
-COPY ./ ./
-
+RUN npx prisma generate
RUN npm run build
-CMD ["npm", "run", "docker:migrate:dev"]
\ No newline at end of file
+
+CMD ["npm", "run", "start"]
+############################################################
+FROM node:18-alpine AS dev
+WORKDIR /usr/src/app
+COPY --from=base /usr/src/app/ .
+
+RUN npx prisma generate
+CMD ["npm", "run", "dev"]
+
+
+
+
+
diff --git a/Dockerfile.dev b/Dockerfile.dev
deleted file mode 100644
index b096ce959..000000000
--- a/Dockerfile.dev
+++ /dev/null
@@ -1,9 +0,0 @@
-FROM node:18-alpine
-
-WORKDIR /usr/src/app
-COPY package*.json ./
-RUN npm ci
-
-COPY ./ ./
-
-CMD ["npm", "run", "docker:migrate:dev"]
\ No newline at end of file
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index 30c5d6fef..eae9e0433 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -4,7 +4,8 @@ services:
projectnext:
build:
context: ./
- dockerfile: ./Dockerfile.dev
+ dockerfile: ./Dockerfile
+ target: dev
ports:
- 3000:3000
volumes:
diff --git a/docker-compose.yml b/docker-compose.yml
index b66efc651..66db6af3d 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -5,12 +5,17 @@ services:
build:
context: ./
dockerfile: ./Dockerfile
+ target: prod
ports:
- 3000:3000
environment:
DB_URI: ${DB_URI}
GOOGLE_MAPS_API_KEY: ${GOOGLE_MAPS_API_KEY}
NODE_ENV: production
+ depends_on:
+ - db
+ links:
+ - db
db:
image: postgres:16.0-alpine
diff --git a/package.json b/package.json
index 3cd14e834..638d92cca 100644
--- a/package.json
+++ b/package.json
@@ -6,8 +6,7 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
- "lint": "next lint",
- "docker:migrate:dev": "npx prisma migrate dev --name init && next dev"
+ "lint": "next lint"
},
"prisma": {
"schema": "src/prisma/schema.prisma"
diff --git a/scripts/start.dev.sh b/scripts/start.dev.sh
deleted file mode 100644
index 9b096ac87..000000000
--- a/scripts/start.dev.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-npx prisma migrate dev --name init && npm run dev
\ No newline at end of file
diff --git a/scripts/start.sh b/scripts/start.sh
deleted file mode 100644
index c292369a6..000000000
--- a/scripts/start.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-echo "Not implemented yet"
\ No newline at end of file
diff --git a/src/app/components/Loader/Loader.js b/src/app/components/Loader/Loader.js
new file mode 100644
index 000000000..1b0b61a2a
--- /dev/null
+++ b/src/app/components/Loader/Loader.js
@@ -0,0 +1,13 @@
+import styles from './Loader.module.scss'
+import logo from '@/images/logo_simple.png'
+import Image from 'next/image'
+
+function Loader() {
+ return (
+
+
+
+ )
+}
+
+export default Loader
\ No newline at end of file
diff --git a/src/app/components/Loader/Loader.module.scss b/src/app/components/Loader/Loader.module.scss
new file mode 100644
index 000000000..b47851f3a
--- /dev/null
+++ b/src/app/components/Loader/Loader.module.scss
@@ -0,0 +1,5 @@
+@use '@/styles/ohma';
+
+.Loader {
+
+}
\ No newline at end of file
From bc7518145224e8cc0c8535f25c00321f21450726 Mon Sep 17 00:00:00 2001
From: JohanHjelsethStorstad
<82723971+JohanHjelsethStorstad@users.noreply.github.com>
Date: Thu, 19 Oct 2023 18:28:14 +0200
Subject: [PATCH 05/13] fix: deleted wrong Dockerfile
---
Dockerfile | 21 +++++++++++++++++++++
Dockerfile.dev | 9 ---------
2 files changed, 21 insertions(+), 9 deletions(-)
create mode 100644 Dockerfile
delete mode 100644 Dockerfile.dev
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 000000000..664182c90
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,21 @@
+FROM node:18-alpine AS base
+WORKDIR /usr/src/app
+COPY package*.json ./
+RUN npm ci
+COPY . .
+############################################################
+FROM node:18-alpine AS prod
+WORKDIR /usr/src/app
+COPY --from=base /usr/src/app/ .
+
+RUN npx prisma generate
+RUN npm run build
+
+CMD ["npm", "run", "start"]
+############################################################
+FROM node:18-alpine AS dev
+WORKDIR /usr/src/app
+COPY --from=base /usr/src/app/ .
+
+RUN npx prisma generate
+CMD ["npm", "run", "dev"]
\ No newline at end of file
diff --git a/Dockerfile.dev b/Dockerfile.dev
deleted file mode 100644
index 052495f8d..000000000
--- a/Dockerfile.dev
+++ /dev/null
@@ -1,9 +0,0 @@
-FROM node:18-alpine
-
-WORKDIR /usr/src/app
-COPY package*.json ./
-RUN npm ci
-
-COPY ./ ./
-
-CMD ["npm", "run", "migrate:dev"]
\ No newline at end of file
From 36f76615dbba8e34afac03a426011edf1fc88097 Mon Sep 17 00:00:00 2001
From: JohanHjelsethStorstad
<82723971+JohanHjelsethStorstad@users.noreply.github.com>
Date: Tue, 24 Oct 2023 14:20:33 +0200
Subject: [PATCH 06/13] feat: dev now works
---
Dockerfile | 3 ++-
docker-compose.dev.yml | 23 ++++++++++++++++++++++-
docker-compose.yml | 18 ++++++++++++++++++
src/app/api/users/route.js | 7 +++++--
src/prisma/Dockerfile | 21 +++++++++++++++++++++
5 files changed, 68 insertions(+), 4 deletions(-)
create mode 100644 src/prisma/Dockerfile
diff --git a/Dockerfile b/Dockerfile
index 664182c90..78d2ad585 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,8 +9,8 @@ WORKDIR /usr/src/app
COPY --from=base /usr/src/app/ .
RUN npx prisma generate
-RUN npm run build
+RUN npm run build
CMD ["npm", "run", "start"]
############################################################
FROM node:18-alpine AS dev
@@ -18,4 +18,5 @@ WORKDIR /usr/src/app
COPY --from=base /usr/src/app/ .
RUN npx prisma generate
+
CMD ["npm", "run", "dev"]
\ No newline at end of file
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index eae9e0433..02b2f496c 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -10,12 +10,15 @@ services:
- 3000:3000
volumes:
- ./src:/usr/src/app/src
+ - ./package.json:/usr/src/app/package.json
+ - ./package-lock.json:/usr/src/app/package-lock.json
environment:
- DB_URI: ${DB_URI}
+ DB_URI: postgresql://${DB_USERNAME}:${DB_PASSWORD}@localhost:5432/${DB_NAME}
GOOGLE_MAPS_API_KEY: ${GOOGLE_MAPS_API_KEY}
NODE_ENV: development
depends_on:
- db
+ - prisma
links:
- db
@@ -30,6 +33,24 @@ services:
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- devdb:/var/lib/postgresql/data
+ healthcheck:
+ test: ["CMD-SHELL", "sh -c 'pg_isready -U ${DB_USERNAME} -d ${DB_NAME}'"]
+ interval: 3s
+ timeout: 3s
+ retries: 10
+
+ prisma:
+ build:
+ context: ./src/prisma
+ dockerfile: ./Dockerfile
+ target: dev
+ environment:
+ DB_URI: postgresql://${DB_USERNAME}:${DB_PASSWORD}@db:5432/${DB_NAME}
+ depends_on:
+ db:
+ condition: service_healthy
+ links:
+ - db
volumes:
devdb:
diff --git a/docker-compose.yml b/docker-compose.yml
index 66db6af3d..cb9453fa2 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -28,6 +28,24 @@ services:
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- proddb:/var/lib/postgresql/data
+ healthcheck:
+ test: ["CMD-SHELL", "sh -c 'pg_isready -U ${DB_USERNAME} -d ${DB_NAME}'"]
+ interval: 3s
+ timeout: 3s
+ retries: 10
+
+ prisma:
+ build:
+ context: ./src/prisma
+ dockerfile: ./Dockerfile
+ target: dev
+ environment:
+ DB_URI: postgresql://${DB_USERNAME}:${DB_PASSWORD}@db:5432/${DB_NAME}
+ depends_on:
+ db:
+ condition: service_healthy
+ links:
+ - db
volumes:
proddb:
diff --git a/src/app/api/users/route.js b/src/app/api/users/route.js
index f1626c41d..a8c2dea46 100644
--- a/src/app/api/users/route.js
+++ b/src/app/api/users/route.js
@@ -32,8 +32,11 @@ export async function POST(req) {
if (
error instanceof Prisma.PrismaClientKnownRequestError &&
error.code === 'P2002'
- ) {
+ )
+ {
return Response.json({}, { status: 409 })
- }
+ }
+
+ throw error
}
}
\ No newline at end of file
diff --git a/src/prisma/Dockerfile b/src/prisma/Dockerfile
new file mode 100644
index 000000000..430e3f4cb
--- /dev/null
+++ b/src/prisma/Dockerfile
@@ -0,0 +1,21 @@
+#This container is responisble for running migrations
+
+FROM node:18-alpine AS base
+WORKDIR /usr/src/app
+RUN npm i prisma
+COPY . .
+
+###################################################
+FROM node:18-alpine AS prod
+WORKDIR /usr/src/app
+COPY --from=base /usr/src/app .
+
+CMD ["npx", "prisma", "migrate", "dev"]
+
+###################################################
+FROM node:18-alpine AS dev
+
+WORKDIR /usr/src/app
+COPY --from=base /usr/src/app .
+
+CMD ["npx", "prisma", "migrate", "dev"]
\ No newline at end of file
From 429a373a4e636395d7fb4266250395f34e4317f0 Mon Sep 17 00:00:00 2001
From: JohanHjelsethStorstad
<82723971+JohanHjelsethStorstad@users.noreply.github.com>
Date: Wed, 25 Oct 2023 19:06:49 +0200
Subject: [PATCH 07/13] fix: docker-compose.yml target: prod
---
docker-compose.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docker-compose.yml b/docker-compose.yml
index cb9453fa2..088f05b11 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -38,7 +38,7 @@ services:
build:
context: ./src/prisma
dockerfile: ./Dockerfile
- target: dev
+ target: prod
environment:
DB_URI: postgresql://${DB_USERNAME}:${DB_PASSWORD}@db:5432/${DB_NAME}
depends_on:
From 311676696cb23c68c6db590d04baf9262e61ecb1 Mon Sep 17 00:00:00 2001
From: JohanHjelsethStorstad
<82723971+JohanHjelsethStorstad@users.noreply.github.com>
Date: Wed, 25 Oct 2023 20:54:19 +0200
Subject: [PATCH 08/13] fix: add name to migration to make it work always
---
.dockerignore | 4 ++++
Dockerfile | 10 ++++++----
default.env | 2 --
docker-compose.dev.yml | 5 ++++-
docker-compose.yml | 27 ++++++++++++++-------------
src/prisma/Dockerfile | 13 ++++++-------
src/prisma/schema.prisma | 5 +----
7 files changed, 35 insertions(+), 31 deletions(-)
diff --git a/.dockerignore b/.dockerignore
index 98ba252ae..8ba188cba 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -3,5 +3,9 @@ npm-debug.log
build
.next
+#you should be explicit in docker-compose about what env-vars should be loaded into a container
+.env
+default.env
+
# prisma
src/prisma/migrations
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index 78d2ad585..85995ab7d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,15 +1,19 @@
FROM node:18-alpine AS base
WORKDIR /usr/src/app
+
COPY package*.json ./
RUN npm ci
+
+RUN mkdir -p src/prisma
+COPY src/prisma/schema.prisma ./src/prisma/
+RUN npx prisma generate
+
COPY . .
############################################################
FROM node:18-alpine AS prod
WORKDIR /usr/src/app
COPY --from=base /usr/src/app/ .
-RUN npx prisma generate
-
RUN npm run build
CMD ["npm", "run", "start"]
############################################################
@@ -17,6 +21,4 @@ FROM node:18-alpine AS dev
WORKDIR /usr/src/app
COPY --from=base /usr/src/app/ .
-RUN npx prisma generate
-
CMD ["npm", "run", "dev"]
\ No newline at end of file
diff --git a/default.env b/default.env
index 014f32513..449048bff 100644
--- a/default.env
+++ b/default.env
@@ -2,5 +2,3 @@ GOOGLE_MAPS_API_KEY=HMMMMMMMMM
DB_NAME=devdb
DB_USERNAME=user
DB_PASSWORD=password
-
-DB_URI="postgresql://${DB_USERNAME}:${DB_PASSWORD}@db:5432/${DB_NAME}"
\ No newline at end of file
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index 02b2f496c..d5504020f 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -12,8 +12,9 @@ services:
- ./src:/usr/src/app/src
- ./package.json:/usr/src/app/package.json
- ./package-lock.json:/usr/src/app/package-lock.json
+ - ./src/prisma/schema.prisma:/usr/src/app/src/prisma/schema.prisma
environment:
- DB_URI: postgresql://${DB_USERNAME}:${DB_PASSWORD}@localhost:5432/${DB_NAME}
+ DB_URI: postgresql://${DB_USERNAME}:${DB_PASSWORD}@db:5432/${DB_NAME}
GOOGLE_MAPS_API_KEY: ${GOOGLE_MAPS_API_KEY}
NODE_ENV: development
depends_on:
@@ -46,6 +47,8 @@ services:
target: dev
environment:
DB_URI: postgresql://${DB_USERNAME}:${DB_PASSWORD}@db:5432/${DB_NAME}
+ volumes:
+ - ./src/prisma/schema.prisma:/usr/src/app/schema.prisma
depends_on:
db:
condition: service_healthy
diff --git a/docker-compose.yml b/docker-compose.yml
index 088f05b11..e12662e5d 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -9,11 +9,12 @@ services:
ports:
- 3000:3000
environment:
- DB_URI: ${DB_URI}
+ DB_URI: postgresql://${DB_USERNAME}:${DB_PASSWORD}@db:5432/${DB_NAME}
GOOGLE_MAPS_API_KEY: ${GOOGLE_MAPS_API_KEY}
NODE_ENV: production
depends_on:
- db
+ - prisma
links:
- db
@@ -34,18 +35,18 @@ services:
timeout: 3s
retries: 10
- prisma:
- build:
- context: ./src/prisma
- dockerfile: ./Dockerfile
- target: prod
- environment:
- DB_URI: postgresql://${DB_USERNAME}:${DB_PASSWORD}@db:5432/${DB_NAME}
- depends_on:
- db:
- condition: service_healthy
- links:
- - db
+ prisma:
+ build:
+ context: ./src/prisma
+ dockerfile: ./Dockerfile
+ target: prod
+ environment:
+ DB_URI: postgresql://${DB_USERNAME}:${DB_PASSWORD}@db:5432/${DB_NAME}
+ depends_on:
+ db:
+ condition: service_healthy
+ links:
+ - db
volumes:
proddb:
diff --git a/src/prisma/Dockerfile b/src/prisma/Dockerfile
index 430e3f4cb..1b6d4072d 100644
--- a/src/prisma/Dockerfile
+++ b/src/prisma/Dockerfile
@@ -1,21 +1,20 @@
#This container is responisble for running migrations
-
FROM node:18-alpine AS base
WORKDIR /usr/src/app
RUN npm i prisma
-COPY . .
+RUN npx prisma init
+COPY schema.prisma ./
-###################################################
+########################################################
FROM node:18-alpine AS prod
WORKDIR /usr/src/app
COPY --from=base /usr/src/app .
-CMD ["npx", "prisma", "migrate", "dev"]
+CMD ["npx", "prisma", "migrate", "deploy", "--name", "docker-migration", "--skip-generate"]
-###################################################
+########################################################
FROM node:18-alpine AS dev
-
WORKDIR /usr/src/app
COPY --from=base /usr/src/app .
-CMD ["npx", "prisma", "migrate", "dev"]
\ No newline at end of file
+CMD ["npx", "prisma", "migrate", "dev", "--name" , "docker-migration", "--skip-generate"]
\ No newline at end of file
diff --git a/src/prisma/schema.prisma b/src/prisma/schema.prisma
index 41f9512d3..a415b9dd2 100644
--- a/src/prisma/schema.prisma
+++ b/src/prisma/schema.prisma
@@ -1,6 +1,3 @@
-// This is your Prisma schema file,
-// learn more about it in the docs: https://pris.ly/d/prisma-schema
-
generator client {
provider = "prisma-client-js"
}
@@ -17,4 +14,4 @@ model User {
email String @unique
@@map("users")
-}
\ No newline at end of file
+}
From 9af42bec3e2ce6d5d619d46884209661ba9e6fa8 Mon Sep 17 00:00:00 2001
From: JohanHjelsethStorstad
<82723971+JohanHjelsethStorstad@users.noreply.github.com>
Date: Wed, 25 Oct 2023 21:09:49 +0200
Subject: [PATCH 09/13] fix: migrate deploy invalid options
---
src/prisma/Dockerfile | 3 ++-
src/prisma/seed.js | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 src/prisma/seed.js
diff --git a/src/prisma/Dockerfile b/src/prisma/Dockerfile
index 1b6d4072d..cb3033217 100644
--- a/src/prisma/Dockerfile
+++ b/src/prisma/Dockerfile
@@ -10,7 +10,8 @@ FROM node:18-alpine AS prod
WORKDIR /usr/src/app
COPY --from=base /usr/src/app .
-CMD ["npx", "prisma", "migrate", "deploy", "--name", "docker-migration", "--skip-generate"]
+#DEPLOY NOT IMPLEMENTED YET: should be npy prisma migrate deploy.
+CMD ["npx", "prisma", "migrate", "dev", "--name" , "docker-migration", "--skip-generate"]
########################################################
FROM node:18-alpine AS dev
diff --git a/src/prisma/seed.js b/src/prisma/seed.js
new file mode 100644
index 000000000..4650c44ff
--- /dev/null
+++ b/src/prisma/seed.js
@@ -0,0 +1,17 @@
+import { PrismaClient } from '@prisma/client'
+const prisma = new PrismaClient()
+async function main() {
+ const harambe = await prisma.user.upsert({
+ create: {
+ email: 'harambe@harambesen.io',
+ },
+ })
+ console.log({ alice })
+}
+main().then(async () => {
+ await prisma.$disconnect()
+}).catch(async (e) => {
+ console.error(e)
+ await prisma.$disconnect()
+ process.exit(1)
+})
\ No newline at end of file
From 30821a2e17a806b5db22a358a245542dc147b026 Mon Sep 17 00:00:00 2001
From: JohanHjelsethStorstad
<82723971+JohanHjelsethStorstad@users.noreply.github.com>
Date: Wed, 25 Oct 2023 23:20:58 +0200
Subject: [PATCH 10/13] feat: add seeding
---
src/prisma/Dockerfile | 7 ++++++-
src/prisma/seed.js | 14 ++++++++++++--
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/prisma/Dockerfile b/src/prisma/Dockerfile
index cb3033217..6d324261c 100644
--- a/src/prisma/Dockerfile
+++ b/src/prisma/Dockerfile
@@ -1,6 +1,7 @@
#This container is responisble for running migrations
FROM node:18-alpine AS base
WORKDIR /usr/src/app
+RUN npm init es6
RUN npm i prisma
RUN npx prisma init
COPY schema.prisma ./
@@ -18,4 +19,8 @@ FROM node:18-alpine AS dev
WORKDIR /usr/src/app
COPY --from=base /usr/src/app .
-CMD ["npx", "prisma", "migrate", "dev", "--name" , "docker-migration", "--skip-generate"]
\ No newline at end of file
+RUN npm install @prisma/client
+RUN npx prisma generate
+COPY seed.js ./
+
+CMD ["/bin/sh", "-c", "npx prisma migrate dev --name docker-migration --skip-generate; node seed.js"]
\ No newline at end of file
diff --git a/src/prisma/seed.js b/src/prisma/seed.js
index 4650c44ff..61117e49d 100644
--- a/src/prisma/seed.js
+++ b/src/prisma/seed.js
@@ -1,12 +1,22 @@
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
+
+console.log("seed starting...")
async function main() {
const harambe = await prisma.user.upsert({
+ where: {
+ email: 'harambe@harambesen.io'
+ },
+ update: {
+
+ },
create: {
- email: 'harambe@harambesen.io',
+ firstname: "Harambe",
+ lastname: "Harambesen",
+ email: 'harambe@harambesen.io',
},
})
- console.log({ alice })
+ console.log({ harambe })
}
main().then(async () => {
await prisma.$disconnect()
From 7070ede9cd0faf8f7699ee93759f544941c015af Mon Sep 17 00:00:00 2001
From: JohanHjelsethStorstad
<82723971+JohanHjelsethStorstad@users.noreply.github.com>
Date: Thu, 26 Oct 2023 10:57:14 +0200
Subject: [PATCH 11/13] chore: update readme
---
README.md | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 0eea1ed8f..8e3ae09f0 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,49 @@
## Config
+
You need a .env file (this file is gitignored). You can find default values in default.env.
Either copy theese to ./.env file or use the --env-file default.env flag when building
## Development
-You have to run veven alongside this project to get access to the api and database. So have veven running in its docker-containers.
-Then run:
+Have the docker deamon running, then run:
+
```bash
docker-compose -f docker-compose.dev.yml up --build
```
+#### Working with the DB
+
+To remigrate the db, just rerun the prisma container
+To regenerate the client-libary from the schema file run:
+
+```bash
+npx prisma generate
+```
+
+in the projectnext container
+
+#### Reinstalling node_modules
+
+Since we are using volumes in dev, the dev container should keep itself up to date with your working directory. But you will need to reinstall packages manually in projectnext upon changing package.json. Run:
+
+```bash
+npm ci
+```
+
+inside projectnext-container
+
## Production
+
This project is not meant to be deployed, but a build can be made by running
+
```bash
docker-compose up --build
```
## Lint
+
To lint the project run
+
```bash
npm run lint
```
From 8ec22fe63c07546dddc274d97c979fea06349a48 Mon Sep 17 00:00:00 2001
From: Paulius Juzenas <59730296+Paulijuz@users.noreply.github.com>
Date: Thu, 26 Oct 2023 15:47:11 +0200
Subject: [PATCH 12/13] chore: add seed.js to prisma config
---
package.json | 3 ++-
src/prisma/Dockerfile | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/package.json b/package.json
index 638d92cca..1e1e63c3c 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,8 @@
"lint": "next lint"
},
"prisma": {
- "schema": "src/prisma/schema.prisma"
+ "schema": "src/prisma/schema.prisma",
+ "seed": "node src/prisma/seed.js"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.4.2",
diff --git a/src/prisma/Dockerfile b/src/prisma/Dockerfile
index 6d324261c..f20d6f0da 100644
--- a/src/prisma/Dockerfile
+++ b/src/prisma/Dockerfile
@@ -23,4 +23,4 @@ RUN npm install @prisma/client
RUN npx prisma generate
COPY seed.js ./
-CMD ["/bin/sh", "-c", "npx prisma migrate dev --name docker-migration --skip-generate; node seed.js"]
\ No newline at end of file
+CMD ["/bin/sh", "-c", "npx prisma migrate dev --name docker-migration --skip-generate; npx prisma db seed"]
\ No newline at end of file
From d2ef394cb6f8d6dae96de356ef5ca0d3c60b1e2a Mon Sep 17 00:00:00 2001
From: Paulius Juzenas <59730296+Paulijuz@users.noreply.github.com>
Date: Thu, 26 Oct 2023 16:22:12 +0200
Subject: [PATCH 13/13] chore: undo seed change in prisma dockerfile
---
src/prisma/Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/prisma/Dockerfile b/src/prisma/Dockerfile
index f20d6f0da..6d324261c 100644
--- a/src/prisma/Dockerfile
+++ b/src/prisma/Dockerfile
@@ -23,4 +23,4 @@ RUN npm install @prisma/client
RUN npx prisma generate
COPY seed.js ./
-CMD ["/bin/sh", "-c", "npx prisma migrate dev --name docker-migration --skip-generate; npx prisma db seed"]
\ No newline at end of file
+CMD ["/bin/sh", "-c", "npx prisma migrate dev --name docker-migration --skip-generate; node seed.js"]
\ No newline at end of file