title: Create-React-App not reading environment variable from docker-compose.yml
body: <pre><code>version: "3"
  services:
    web:
      # replace username/repo:tag with your name and image details
      image: user1/webapp:latest
      volumes:
        - ./local-db:/go/src/webapp/local-db
      environment:
        - REACT_APP_ENDPOINT=http://api.com
      deploy:
        replicas: 5
        resources:
          limits:
            cpus: "0.1"
            memory: 50M
        restart_policy:
          condition: on-failure
      ports:
        - "8080:8080"
      networks:
        - webnet
  networks:
    webnet:
  </code></pre>
  
  <p><code>webapp</code> is server that serves a create-react-app but when I run </p>
  
  <pre><code>console.log("process.env.REACT_APP_ENDPOINT")
  console.log(process.env.REACT_APP_ENDPOINT)
  </code></pre>
  
  <p>according to <a href="https://daveceddia.com/multiple-environments-with-react/" rel="noreferrer">https://daveceddia.com/multiple-environments-with-react/</a>
  I should be able to access the environment variables. I run the docker-compose using </p>
  
  <pre><code>docker swarm init 
  docker stack deploy -c ~/webapp/docker-compose.yml webapp 
  </code></pre>
  
  <p>The console log prints <code>undefined</code> but if I run the server serving create-react-app on my local machine without docker, the frontend properly prints the environment variable.</p>