kutt icon indicating copy to clipboard operation
kutt copied to clipboard

Frontend build not reflected by modified .env

Open simonwep opened this issue 5 years ago • 6 comments

Options such as DISALLOW_REGISTRATION and DISALLOW_ANONYMOUS_LINKS are used on the client page and since the docker images come with prebuild frontend you'll only get an error message if you try to shorten a link when DISALLOW_ANONYMOUS_LINKS is set to false so instead of hiding a page altogether and redirecting the user to /login you'll get an error message:

image

Is this a known issue or am I doing something wrong? I copied the docker-compose.yml file and copied the content of .docker.env in the .env file, made my changes (including setting both previously mentioned keys to false) and started the app using docker-compose up.

My env:

Ubuntu 18.04.5 LTS (Bionic Beaver)
Docker version 19.03.12, build 48a66213fe
docker-compose version 1.26.2, build eefe0d31

simonwep avatar Sep 23 '20 14:09 simonwep

in next.config.js the package dotenv is used to merge a .env file into process.env environment variables:

const { parsed: localEnv } = require("dotenv").config();

module.exports = {
  publicRuntimeConfig: {
    CONTACT_EMAIL: localEnv && localEnv.CONTACT_EMAIL,
    SITE_NAME: localEnv && localEnv.SITE_NAME,
    DEFAULT_DOMAIN: localEnv && localEnv.DEFAULT_DOMAIN,
    RECAPTCHA_SITE_KEY: localEnv && localEnv.RECAPTCHA_SITE_KEY,
    GOOGLE_ANALYTICS: localEnv && localEnv.GOOGLE_ANALYTICS,
    REPORT_EMAIL: localEnv && localEnv.REPORT_EMAIL,
    DISALLOW_ANONYMOUS_LINKS: localEnv && localEnv.DISALLOW_ANONYMOUS_LINKS,
    DISALLOW_REGISTRATION: localEnv && localEnv.DISALLOW_REGISTRATION,
    SENTRY_PUBLIC_DSN: localEnv && localEnv.SENTRY_PUBLIC_DSN,
  }
};

parsed contains the parsed contents of such a .env file but this is not the merged output of "native" process.env + .env file and from my understanding nothing speaks against using the merged output, e.g. process.env.

grischaerbe avatar Oct 19 '20 22:10 grischaerbe

doesn't work for me either. try using dotenv-flow

ralyodio avatar Dec 07 '20 08:12 ralyodio

$ curl localhost:8017 curl: (56) Recv failure: Connection reset by peer

ralyodio avatar Dec 07 '20 08:12 ralyodio

Found a simple way to solve .env changes reflect on frontend.

From ".dockerignore" just remove ".env" after that just rebuild it.

davidpirates avatar Jun 28 '21 07:06 davidpirates

Is there a way to set these variables without using volumes or rebuilding the image?

akahenry avatar Jan 11 '22 15:01 akahenry

Solution that allegedly works by using volumes, not sure about a solution without volumes yet: https://github.com/thedevs-network/kutt/issues/365#issuecomment-743462223

elimisteve avatar Jan 30 '22 14:01 elimisteve