ether / etherpad-next

Rewrite of Etherpad using NextJS
Apache License 2.0
7 stars 3 forks source link

feat(docker): introduce #67

Closed JannikStreek closed 5 months ago

JannikStreek commented 5 months ago

Description

Adds docker support

Related Issues

closes #66

JannikStreek commented 5 months ago

@AugustinMauroy database is configurable from compose setup, but I made Postgres the default as I think its the most used default option nowadays

AugustinMauroy commented 5 months ago

@JannikStreek did you test with prisma client ?

JannikStreek commented 5 months ago

@JannikStreek did you test with prisma client ?

generate works - or which commands would you test?

AugustinMauroy commented 5 months ago

generate works - or which commands would you test?

If you run an dev env you should have an get api entry point at /api/pad it's create on pad if there are no pad on db and if there are one ore more it's send JSON data.

I'm not able to test now. But we need to test if it's work with mysql and posgress

JannikStreek commented 5 months ago

generate works - or which commands would you test?

If you run an dev env you should have an get api entry point at /api/pad it's create on pad if there are no pad on db and if there are one ore more it's send JSON data.

I'm not able to test now. But we need to test if it's work with mysql and posgress

it works (for Postgres). what's the preferred way in development to create the schema? the command npm run db:migrate wants to create a migration file - which shouldn't be the case at least now...so I have used npx prisma db push (create schema with bypassing migrations). I haven't found anything in the tech docs regarding that. So I added that as well to the docker setup instructions.

AugustinMauroy commented 5 months ago

it works (for Postgres). what's the preferred way in development to create the schema? the command npm run db:migrate wants to create a migration file - which shouldn't be the case at least now...so I have used npx prisma db push (create schema with bypassing migrations). I haven't found anything in the tech docs regarding that. So I added that as well to the docker setup instructions.

Honestly, I'm not an expert on Prisma. So for the moment, if the little API works for me, that's OK. We'll rectify the situation if necessary in the future.

AugustinMauroy commented 5 months ago

I've run the commands that are in the technical docs for a dev environment. And the Prisma client doesn't build.

JannikStreek commented 5 months ago

I've run the commands that are in the technical docs for a dev environment. And the Prisma client doesn't build.

so for Postgres, right? or for mysql?

AugustinMauroy commented 5 months ago

so for Postgres, right? or for mysql?

Postgres.

So what I do

JannikStreek commented 5 months ago

so for Postgres, right? or for mysql?

Postgres.

So what I do

  • start docker
  • cp .env.example cp .env
  • fill with it with dev for every entry
  • run command specify on docs.

I missed the app part in the docker compose exec app npx prisma db push command in the docs. Fixed it. Maybe thats where it didn't work out? Where exactly did you have trouble with?

AugustinMauroy commented 5 months ago

I missed the app part in the docker compose exec app npx prisma db push command in the docs. Fixed it. Maybe thats where it didn't work out? Where exactly did you have trouble with?

gotcha, it's should work. I'm at school so I cannot test if it's work on my machine.

AugustinMauroy commented 5 months ago

Hey ! I foolishly followed the guide to run the dev environment and this is what I got. I think something needs to be done. So .env:

DATABASE_PROVIDER=postgresql

# Docker compose variables
POSTGRES_PASSWORD=dev
POSTGRES_USER=dev
POSTGRES_DB=etherpad-next

# In case you don't use docker compose
# DATABASE_URL=postgresql://postgres-user:postgres-password@postgres:5432/etherpad-next

and I got

PrismaClientInitializationError: Authentication failed against database server at `postgres`, the provided database credentials for `dev` are not valid.
JannikStreek commented 5 months ago

Hey ! I foolishly followed the guide to run the dev environment and this is what I got. I think something needs to be done. So .env:

DATABASE_PROVIDER=postgresql

# Docker compose variables
POSTGRES_PASSWORD=dev
POSTGRES_USER=dev
POSTGRES_DB=etherpad-next

# In case you don't use docker compose
# DATABASE_URL=postgresql://postgres-user:postgres-password@postgres:5432/etherpad-next

and I got

PrismaClientInitializationError: Authentication failed against database server at `postgres`, the provided database credentials for `dev` are not valid.

you most likely have an existing db. try docker compose down -v and then the up command again.

AugustinMauroy commented 5 months ago

you most likely have an existing db. try docker compose down -v and then the up command again.

ok finally work. Sorry I'm not docker expert

AugustinMauroy commented 5 months ago

@SamTV12345 i want your opinion

SamTV12345 commented 5 months ago

I'll take a look at it. Haven't worked with Prisma yet but the docker stuff seems to be fine. That maybe explains why next was always building with webpack on my machine. Don't have turbo installed locally.

AugustinMauroy commented 5 months ago

That maybe explains why next was always building with webpack on my machine. Don't have turbo installed locally.

Like explain to @JannikStreek there are two tools call turbo (Vercel want to merge it). One turborepo we use it for dev/build caching. and second turbopack use in dev env for nextjs to compile and HMR, it's will come for building. So yeah nextjs still use webpack as builder

SamTV12345 commented 5 months ago

When I run npx prisma generate it generates something along the lines of \prisma\@prisma\client\mysql. Is this still the old mysql client or the new postgres client but without the renaming?

SamTV12345 commented 5 months ago

Other than that. Schema generation worked without a problem :). Well done.

JannikStreek commented 5 months ago

When I run npx prisma generate it generates something along the lines of \prisma@prisma\client\mysql. Is this still the old mysql client or the new postgres client but without the renaming?

I left the mysql generator in the code, alongside with the default one for Postgres. I imagine it's created due to that. I just left it there because I wasn't sure anyone wants to continue with mysql in a local setup.

@AugustinMauroy Docker usage is optional, but docker reaps many benefits in a multi developer setup. Otherwise there will always the famous "works on my machine" phrase. with docker we can each have the exact same setup. Thats what I like about it.

I would merge this then, if there are no more open issues.

SamTV12345 commented 5 months ago

Ah alright. Sure feel free to merge this. Thanks :).