cryptag / leapchat

Ephemeral, encrypted, in-browser chat rooms
https://www.leapchat.org/
Other
184 stars 32 forks source link

docker compose rework #256

Open jimmcgaw opened 1 year ago

jimmcgaw commented 1 year ago

What's in this PR:

  1. A Dockerfile was created for building the leapchat server as a go binary docker image.
  2. A Dockerfile was created for building a frontend image.
  3. Updated the docker compose file to build the frontend image, go server image, as well as the two database images.
  4. Updated the docker-compose file database image steps to include passing the PostgREST config and running the init script in the postgres container.

WIP: have the sql init shell script run in the postgres container when it boots up.

elimisteve commented 1 year ago

Nice PR! Thank you.

I think I have a permanent solution to both the miniware/ issue and a temporary fix for the React dependency hell issue that's good enough for the foreseeable future.

If I solve the former, shall I just push it to this branch? Or shall I branch off of it so you can take a look?

jimmcgaw commented 1 year ago

Nice PR! Thank you.

I think I have a permanent solution to both the miniware/ issue and a temporary fix for the React dependency hell issue that's good enough for the foreseeable future.

If I solve the former, shall I just push it to this branch? Or shall I branch off of it so you can take a look?

Feel free to add whatever to this branch. ⚡

elimisteve commented 1 year ago

@jimmcgaw Just pushed! Got the Go build working. docker compose up now almost works :smile:

elimisteve commented 1 year ago

@jimmcgaw Just pushed! Got the Go build working. docker compose up now almost works smile

@jimmcgaw Want to take it from here with the dockerization? While I work on dependency hell sheeit.

elimisteve commented 1 year ago

What do you think is the best way to make it so we can modify LeapChat source files on our host but have the dev server that's running in Docker update when something changes? Shall we attach a volume (that is the folder containing the source code on the host) to the frontend container from the outside?

elimisteve commented 1 year ago

The database steps might need tweaking. This is just a starting point for doing local development with docker.

Excellent.

I believe the main reason why the Docker config didn't work in the past is because db/init_sql.sh is never executed inside the postgres container.

Just created an issue for this: https://github.com/cryptag/leapchat/issues/257 ...and added it to this new milestone: https://github.com/cryptag/leapchat/milestone/7

elimisteve commented 1 year ago

I think we need to create Dockerfile.postgrest.dev and have it copy db/postgrest.conf into the postgrest container when building it.

elimisteve commented 1 year ago

Created an issue for that: https://github.com/cryptag/leapchat/issues/259

elimisteve commented 1 year ago

Alright, this PR and branch are all yours :sweat_smile: .

In my mind the last remaining things needed to do here in the milestone I made for dockerization: https://github.com/cryptag/leapchat/milestone/7

jimmcgaw commented 1 year ago

I think we need to create Dockerfile.postgrest.dev and have it copy db/postgrest.conf into the postgrest container when building it.

I don't think we need to do that. I create a volume that mounts the /db directory into the container, and a command that runs the postgrest command with the conf file, where it's mounted in the container, when it starts up. If that doesn't work I'll tweak it.

jimmcgaw commented 1 year ago

The database steps might need tweaking. This is just a starting point for doing local development with docker.

Excellent.

I believe the main reason why the Docker config didn't work in the past is because db/init_sql.sh is never executed inside the postgres container.

Just created an issue for this: #257 ...and added it to this new milestone: https://github.com/cryptag/leapchat/milestone/7

Yep. I started a volume mount in postgres container that mounts to /docker-entrypoint-initdb.d/, which is the directory that a postgres container will run scripts out of, if they are present, when initialized. I haven't confirmed that this works yet.

jimmcgaw commented 1 year ago

What do you think is the best way to make it so we can modify LeapChat source files on our host but have the dev server that's running in Docker update when something changes? Shall we attach a volume (that is the folder containing the source code on the host) to the frontend container from the outside?

For the frontend stuff, yes.

For the go, the ideal workflow isn't clear to me yet. I don't think I've ever worked with Docker with a compiled (ie not interpreted or JIT compiled) language. Any ideas there?

elimisteve commented 1 year ago

For the go, the ideal workflow isn't clear to me yet. I don't think I've ever worked with Docker with a compiled (ie not interpreted or JIT compiled) language. Any ideas there?

The Go binary will need to change so infrequently, and it compiles so quickly, that I say we don't worry about having anything watch the file system for changes to .go files; let's just manually rebuild the Go container when we need to.

Sound good?

bhagwatis commented 1 year ago

New to docker and postgrest. I have installed new version of docker. Containers installed posgresql, pgadmin4 and postgrest. Postgrest does not start in the container nor am i able to ping that specific port. Can someone please help me here?