-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from vevcom/refactor/prisma-docker
Refactor/prisma docker
- Loading branch information
Showing
18 changed files
with
184 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
FROM node:18-alpine | ||
|
||
FROM node:18-alpine AS base | ||
WORKDIR /usr/src/app | ||
|
||
# Install node modules | ||
COPY package*.json ./ | ||
RUN npm ci | ||
|
||
COPY ./ ./ | ||
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 npm run build | ||
CMD ["npm", "run", "docker:migrate:dev"] | ||
CMD ["npm", "run", "start"] | ||
############################################################ | ||
FROM node:18-alpine AS dev | ||
WORKDIR /usr/src/app | ||
COPY --from=base /usr/src/app/ . | ||
|
||
CMD ["npm", "run", "dev"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className={styles.Loader}> | ||
<Image src={logo} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default Loader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@use '@/styles/ohma'; | ||
|
||
.Loader { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#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 ./ | ||
|
||
######################################################## | ||
FROM node:18-alpine AS prod | ||
WORKDIR /usr/src/app | ||
COPY --from=base /usr/src/app . | ||
|
||
#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 | ||
WORKDIR /usr/src/app | ||
COPY --from=base /usr/src/app . | ||
|
||
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { PrismaClient } from '@prisma/client' | ||
const prisma = new PrismaClient() | ||
|
||
console.log("seed starting...") | ||
async function main() { | ||
const harambe = await prisma.user.upsert({ | ||
where: { | ||
email: '[email protected]' | ||
}, | ||
update: { | ||
|
||
}, | ||
create: { | ||
firstname: "Harambe", | ||
lastname: "Harambesen", | ||
email: '[email protected]', | ||
}, | ||
}) | ||
console.log({ harambe }) | ||
} | ||
main().then(async () => { | ||
await prisma.$disconnect() | ||
}).catch(async (e) => { | ||
console.error(e) | ||
await prisma.$disconnect() | ||
process.exit(1) | ||
}) |