Skip to content

Commit

Permalink
Use config from index.html in case of docker compose to enable pre-bu…
Browse files Browse the repository at this point in the history
…ilt containers
  • Loading branch information
kelunik committed Mar 8, 2016
1 parent e524bba commit fbe96ec
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ RUN npm install gulp -g
COPY . /app/
WORKDIR "/app"

RUN mv src/js/config.docker.js src/js/config.local.js

RUN npm install
RUN gulp production

Expand Down
3 changes: 3 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<link rel="stylesheet" href="/screen.css">
<link rel="icon" href="/favicon.ico">
<title>CrowdControl</title>

<meta name="crowdcontrol:api:url" content="${API_URL}">
<meta name="crowdcontrol:api:auth" content="${API_AUTH}">
</head>
<body>
<script src="https://www.promisejs.org/polyfills/promise-7.0.4.min.js"></script>
Expand Down
18 changes: 18 additions & 0 deletions src/js/config.docker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
let meta = (name) => {
var metas = document.getElementsByTagName("meta");

for (var i = 0; i < metas.length; i++) {
if (metas[i].getAttribute("name") == name) {
return metas[i].getAttribute("content");
}
}

return "";
};

let config = {
apiRoot: meta("crowdcontrol:api:url"),
authentication: meta("crowdcontrol:api:auth") === "true"
};

export default config;

0 comments on commit fbe96ec

Please sign in to comment.