title: How to configure .env file in Docker-Compose in React?
body: <p>I have added <code>.env</code> in docker ignore and after image is built environment variable is undefined, So how can I configure those environment variable in <code>docker-compose.yml</code> file</p>
  <p><em>Should we also put <code>docker-compose.yml</code> in the ignore ?</em></p>
  <p><strong>docker-compose.yml</strong></p>
  <pre><code>version: '3'
  services: 
      client:
          build: 
              context: .
              dockerfile: Dockerfile.dev
          command: npm start
          container_name: testReact
          ports:
              - &quot;3000:3000&quot;        
          volumes: 
              - ./:/app
              - /app/node_modules
  </code></pre>
  <p><strong>.env</strong></p>
  <pre><code>REACT_APP_CONSTANT = 'MY REACT APP'
  </code></pre>
  <p><strong>.dockerignore</strong></p>
  <pre><code>/node_modules
  /build
  .git
  *.md
  .gitignore
  .env
  </code></pre>