journaly icon indicating copy to clipboard operation
journaly copied to clipboard

💻 DEV - Set up Dockerized option for local development

Open robin-macpherson opened this issue 3 years ago • 10 comments

Description

@JoshuaBelden brought up that suggested that some contributors may prefer to use Docker for local development and kindly offered to take on the work of setting up the necessary configuration and documentation for this with This Approach Doc.

With that approval, let's do it 🙂

robin-macpherson avatar May 05 '21 19:05 robin-macpherson

Hey @robin-macpherson! I can take this one!

JoshuaBelden avatar May 05 '21 19:05 JoshuaBelden

Awesome! Thanks again for all the work on this @JoshuaBelden 🙏🏼

robin-macpherson avatar May 05 '21 19:05 robin-macpherson

Awesome to see this getting under way, in additional the the dev QoL benefits I was thinking this might simplify our automated e2e testing in the future (since that involves standing up a fully functional instance in a CI environment). As mentioned in the other ticket, the build process can but a bit tricky so if you run into any issue with that or anything else let us know, happy to help

Lanny avatar May 08 '21 13:05 Lanny

That's actually great point @Lanny ! I had been thinking about this just the other day as I keep thinking about our Cypress stuff. Hadn't thought of this but it could make that a lot easier.

robin-macpherson avatar May 11 '21 20:05 robin-macpherson

Hey all, just an update. I'm still working through containerization. Without changing a bunch of directory structures to support multiple docker files, I'm trying to set up postgres using strictly docker-compose and a docker file to host the web app. I believe this will work but running into several issues getting the web app up while seeding the database and copying and incorporating different .env files from different sub directories.

All solvable I'm sure, I just need to do some more research on the best approach.

JoshuaBelden avatar May 12 '21 17:05 JoshuaBelden

Awesome, thanks for the update @JoshuaBelden ! We used to set up PostgreSQL directly from docker-compose back when we were Dockerized before which was just something like:

services:
  db:
    image: "postgres:11"
    container_name: "journaly_db"
    ports:
      - "5432:5432"
    volumes:
      - db:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_DB=${POSTGRES_DB}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    restart: always

volumes:
  db:

We then just used single multi-stage Dockerfiles in each service. I'm not sure if that helps but good luck and feel free to let us know if we can help!

robin-macpherson avatar May 14 '21 07:05 robin-macpherson

Also, we always welcome draft PRs just in case you want to put anything up in order to discuss next to your code. But whatever works best for you of course 😊

robin-macpherson avatar May 14 '21 07:05 robin-macpherson

Without changing a bunch of directory structures to support multiple docker files, I'm trying to set up postgres using strictly docker-compose and a docker file to host the web app.

Sounds like a good approach to me!

running into several issues getting the web app up while seeding the database and copying and incorporating different .env files from different sub directories.

I think the only .env file that matters will be in packages/web. Also I haven't super thought this out, but I think docker will auto-load that file, so we should exclude it when COPYing files into the image. This might cause an issue with where we call dotenv.config() in pages/api/graphql.ts so we might just need to remove that line, and I think we need to not add quotation marks per here (which is different than the dotenv lib's behavior).

Like Robin said, feel free to open a draft PR or post stack traces or anything else if we can be helpful on specific issues.

Lanny avatar May 19 '21 15:05 Lanny

That's a great idea @Lanny Thank you. I apologize for dragging my feet on this, I'm super excited to contribute but struggling to get free time to work on this. I'm good with docker on a happy path, so this is pushing what I'm used to, but happy to learn new things.

I definitely will get a draft pr up, so at the very least, you can see where I'm at.

JoshuaBelden avatar May 19 '21 16:05 JoshuaBelden

Great points @Lanny and awesome, thanks @JoshuaBelden ! We totally understand the time struggle so no worries and we're just grateful for you pushing this work forward 😄

robin-macpherson avatar May 19 '21 16:05 robin-macpherson