thedevs-network / kutt

Free Modern URL Shortener.
https://kutt.it
MIT License
8.45k stars 1.1k forks source link

Frontend build not reflected by modified .env #388

Open simonwep opened 4 years ago

simonwep commented 4 years ago

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
grischaerbe commented 4 years ago

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.

ralyodio commented 3 years ago

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

ralyodio commented 3 years ago

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

davidpirates commented 3 years ago

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

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

akahenry commented 2 years ago

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

elimisteve commented 2 years ago

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