Reputation: 18401
I have a config file with API URL under the path "src/config.js":
const API_URL = 'https://some-url-here.com'
export default {
API_URL: API_URL
}
And a Dockerfile:
# build stage
FROM node:9.11.1-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:1.13.12-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
How can i make that API_URL
available to docker, so devops could change that url?
Upvotes: 2
Views: 1557
Reputation: 18401
Using Vue-cli 2.9, you can set ENV variables in a "config" directory.
For example: "config/dev.env.js":
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
API_URL: '"https://server.com"'
})
Then you can use it in your client :
const API_URL = process.env.API_URL
export default {
API_URL: API_URL,
}
Upvotes: 2