Building a project without a database connection #9028
Unanswered
wesdimiceli
asked this question in
Q&A
Replies: 1 comment
-
I do not think payload itself and the admin panel requires the db connection. But if you put any pages which uses payload to fetch data (like probably the templates does). Then it will need to contact payload to build those pages. Try to remove those pages and see if it will build without then. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm in the process of taking our existing production v2 implementation and working through the migration guide for v3. One issue that I can't seem to resolve is getting a NextJS production build without needing to set the secret or Mongo connection details in the config. Right now I'm basically looking at a stock v3 template and trying to run
pnpm build
gives me:Even if I set a dummy secret, it will still fail on attempt to connect to Mongo, depending on what connection string is set in the local environment files. Previously, we had the
disableDBConnect
option but it doesn't seem to be supported by the v3 config.Feels to me like universal best practice is to avoid production secrets in the repo and/or sitting around in developers' .env files, but the example READMEs suggest something along the lines of "copy the .env.example file and fill in the blanks". Which is fine for dev tasks but in order to get a usable docker image I need an environment-agnostic build that I can push to ECR, and putting secrets or database credentials in that image would be a pretty big security violation.
I'm not clear on what the database connection is used for during the build process, but I can imagine there could be a lot of instances where a DB connection is not practical -- e.g. DB lives in a private subnet, or some CI/CD configurations where a local database isn't feasible. Is there any way to achieve what I'm looking to do here? It would be great if there were some official documentation surrounding best practices w.r.t. using an encrypted secrets store like AWS SecretsManager or SSM. As it stands, the current Dockerfile examples don't seem to cover how to handle production secrets.
Beta Was this translation helpful? Give feedback.
All reactions