t3-oss/create-t3-app

feat: Improve docs on deployment with Docker

Opened this issue · 0 comments

Is your feature request related to a problem? Please describe.

The current Dockerfile implementation suggested by the docs could use some more love; currently, there's a runtime error associated with it and poor usage of caching make for significantly longer build times.

Describe the solution you'd like to see

There should be a base step that runs RUN apk add --no-cache libc6-compat openssl and is reused by the other steps to address the runtime error. Also, caching pnpm installs, next builds via a bind mount and leveraging Docker's cache to move around some of the steps could significantly improve performance.

Describe alternate solutions

Maybe bind mounts are a bit too much as I believe you'd have to mount one for pnpm regardless of the package manager used (though I believe that's an important step -- it's a 6x speed boost on a pretty average-sized project I'm developing), but I'm willing to open a PR with the other solutions too :)

Additional information

  1. The Runner stage does not include the openssl package as it uses a different image, which results in a runtime error.
  2. The install step is not cached, ocurring in significant delays.
  3. Separating the Builder and Deps stage when there's a dependency from the Builder stage on the Deps's node_modules introduces unnecessary overhead, as there already is a Runner layer;
  4. Not separating the prisma generate step from the install step occurs in a fresh install of the dependencies every time my prisma.schema changes.