strapi-community / strapi-tool-dockerize

Easy add support for docker to your strapi project
MIT License
558 stars 35 forks source link

What is the reason of env folder? #105

Open alimoli opened 11 months ago

alimoli commented 11 months ago

Feature Request

I am trying to understand what is the purpose of having an /env folder that emulates the configuration already present in Strapi. Example of config/database.ts:

postgres: {
      connection: {
        connectionString: env('DATABASE_URL'),
        host: env('DATABASE_HOST', 'localhost'),
        port: env.int('DATABASE_PORT', 5432),
        database: env('DATABASE_NAME', 'strapi'),
        user: env('DATABASE_USERNAME', 'strapi'),
        password: env('DATABASE_PASSWORD', 'strapi'),
        ssl: env.bool('DATABASE_SSL', false) && {
          key: env('DATABASE_SSL_KEY', undefined),
          cert: env('DATABASE_SSL_CERT', undefined),
          ca: env('DATABASE_SSL_CA', undefined),
          capath: env('DATABASE_SSL_CAPATH', undefined),
          cipher: env('DATABASE_SSL_CIPHER', undefined),
          rejectUnauthorized: env.bool(
            'DATABASE_SSL_REJECT_UNAUTHORIZED',
            true
          ),
        },
        schema: env('DATABASE_SCHEMA', 'public'),
      },
      pool: { min: env.int('DATABASE_POOL_MIN', 2), max: env.int('DATABASE_POOL_MAX', 10) },
    },

My env/database.ts:

export default ({env}) => ({
  connection: {
    client: 'postgres',
    connection: {
      host: env('DATABASE_HOST', undefined),
      port: env.int('DATABASE_PORT', undefined),
      database: env('DATABASE_NAME', undefined),
      user: env('DATABASE_USERNAME', undefined),
      password: env('DATABASE_PASSWORD', undefined),
      ssl: env.bool('DATABASE_SSL', false) && {
        rejectUnauthorized: false
      }
    }
  }
});

Another related question, how does it behave this plugin in case of plugins (f.e. cloudinary)?

Eventyret commented 8 months ago

It's using the cold configuration of strapi and should be updated soon as I'm writing V2. The idea with the old one was to overwrite the .env More info found here https://docs.strapi.io/dev-docs/configurations/environment/#environment-configurations