-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make environment configurable using environment variables (#52)
- Loading branch information
1 parent
0f55aae
commit 2b38568
Showing
7 changed files
with
31 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ RUN npm install -g @angular/[email protected] | |
COPY . /app | ||
|
||
# Build the project and copy the files | ||
RUN npm run ng build -- --deploy-url=/ --prod | ||
RUN npm run ng build -- --deploy-url=/ --c production | ||
|
||
FROM bitnami/nginx:latest | ||
|
||
|
@@ -37,7 +37,17 @@ COPY ./.nginx/nginx.conf /opt/bitnami/nginx/conf/server_blocks/frontend.conf | |
# Copy from the stahg 1 | ||
COPY --from=builder /app/dist/OS2IoT-frontend /app | ||
|
||
## Change user to perform privileged actions | ||
USER 0 | ||
# Install envsubst | ||
RUN apt-get update && apt-get install -y gettext-base | ||
# Make sure we have write access to the env.js file without using the root user | ||
RUN chown 1001 /app/assets/env.js | ||
# Revert to the original non-root user | ||
USER 1001 | ||
|
||
EXPOSE 8080 | ||
EXPOSE 8081 | ||
|
||
ENTRYPOINT ["nginx", "-g", "daemon off;"] | ||
# Substiture placeholders in env.template.js using environment variables overwrite env.js | ||
CMD ["/bin/sh", "-c", "envsubst < /app/assets/env.template.js > /app/assets/env.js && exec nginx -g 'daemon off;'"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// This file will be overwritten when running in Docker using env.template.js and envsubst | ||
(function (window) { | ||
window["env"] = window["env"] || {}; | ||
window["env"].PRODUCTION = false; | ||
window["env"].BASE_URL = 'http://localhost:3000/api/v1/'; // For local testing | ||
window["env"].TABLE_PAGE_SIZE = 20; // For local testing | ||
})(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Variables in this file will be substituted using envsubst | ||
(function (window) { | ||
window["env"] = window["env"] || {}; | ||
window["env"].PRODUCTION = "${PRODUCTION}"; | ||
window["env"].BASE_URL = "${BASE_URL}"; | ||
window["env"].TABLE_PAGE_SIZE = "${TABLE_PAGE_SIZE}"; | ||
})(this); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters