我有下一个 docker-compose 配置
version: '3'
services:
frontend:
image: frontend-image
depends_on:
- backend-image
ports:
- 8081:8081
environment:
- OAUTH_CLIENT="client"
- OAUTH_CLIENT_KEY="Client111"
- BACKEND_HOSTNAME="localhost"
- BACKEND_PORT="8080"
这是前端映像 Dockerfile
FROM quasarframework/quasar-org:1.0.0
WORKDIR /opt/app
COPY package.json /opt/app/package.json
RUN rm -r node_modules
RUN npm install
RUN npm -g install quasar-cli
COPY . /opt/app
EXPOSE 4000
EXPOSE 8081
CMD ["quasar", "dev"]
但是当我执行 console.log(process.env) 我只得到一个属性:
{NODE_ENV:"development"}
前端的一切工作正常,我唯一的问题是环境变量。我的目标是为不同的环境设置不同的环境变量。
码头工人版本
Client:
Version: 17.12.0-ce
API version: 1.35
Go version: go1.9.2
Git commit: c97c6d6
Built: Wed Dec 27 20:11:19 2017
OS/Arch: linux/amd64
Server:
Engine:
Version: 17.12.0-ce
API version: 1.35 (minimum version 1.12)
Go version: go1.9.2
Git commit: c97c6d6
Built: Wed Dec 27 20:09:53 2017
OS/Arch: linux/amd64
Experimental: false
Docker 撰写版本
docker-compose version 1.18.0, build 8dd22a9
docker-py version: 2.6.1
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.1t 3 May 2016