Giter Club home page Giter Club logo

Comments (9)

robigan avatar robigan commented on July 19, 2024 1

Ah thanks for pointing this out, I wasn't aware of it.

Your command override works nicely but it looks a bit inefficient. Would this maybe solve it better? https://stackoverflow.com/a/67927521

Sorry if I wasn't clear, that wasn't a long term suggested patch, that was a patch for anyone coming across this issue. I am not sure that that Stack Overflow answer works as that would be contradictory to the explanation in the docs of as to why this occurs, I'll take a look at other solutions. But officially, the docs tell you to make an API to retrieve those values from the backend.

from bracket.

robigan avatar robigan commented on July 19, 2024 1

I'd do the work myself and provide a PR, but I can't get the backend to init the database, now that v1.4.3 exists I'll try again as I last tried on v.1.2.1

from bracket.

robigan avatar robigan commented on July 19, 2024

This issue came about after a040084 was made

from bracket.

robigan avatar robigan commented on July 19, 2024

Therefore, the NEXT_PUBLIC_ envs set by users of Bracket (who run Bracket using Docker) do not get evaluated during container run, as they're already "inlined" by Next.js

from bracket.

robigan avatar robigan commented on July 19, 2024

Furthermore, per the docs:

Note: After being built, your app will no longer respond to changes to these environment variables. For instance, if you use a Heroku pipeline to promote slugs built in one environment to another environment, or if you build and deploy a single Docker image to multiple environments, all NEXT_PUBLIC_ variables will be frozen with the value evaluated at build time, so these values need to be set appropriately when the project is built. If you need access to runtime environment values, you'll have to setup your own API to provide them to the client (either on demand or during initialization).

from bracket.

robigan avatar robigan commented on July 19, 2024

For the mean time, my suggested patch is to override the CMD instruction, there are various ways to do this. Our solution with docker-compose was to add the line:

services:
  bracket-frontend:
    command: '/bin/sh -c "yarn build && yarn start"'

from bracket.

evroon avatar evroon commented on July 19, 2024

Ah thanks for pointing this out, I wasn't aware of it.

Your command override works nicely but it looks a bit inefficient.
Would this maybe solve it better? https://stackoverflow.com/a/67927521

from bracket.

evroon avatar evroon commented on July 19, 2024

But officially, the docs tell you to make an API to retrieve those values from the backend.

Yeah that was also my initial solution but that doesn't work of course for the NEXT_PUBLIC_API_BASE_URL variable that tells the frontend where to send requests to.

I'll take a look at other solutions

Yeah there must be a lot of projects that are selfhosted and use Next that face the same issue.

from bracket.

robigan avatar robigan commented on July 19, 2024

This looks interesting:
https://dev.to/itsrennyman/manage-nextpublic-environment-variables-at-runtime-with-docker-53dl

Additionally, the dockerfile example in that link provides a good example as to how to reduce the size of the docker images. Currently, I see that the frontend image is weighing in at 3.2GB when built.

from bracket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.