Implemented basic env var stuff
This commit is contained in:
		@@ -14,4 +14,5 @@ RUN npm run build
 | 
			
		||||
 | 
			
		||||
# Stage 2: Package up with the webserver
 | 
			
		||||
FROM nginx:alpine AS final
 | 
			
		||||
COPY --from=build /build/dist/frontend /usr/share/nginx/html
 | 
			
		||||
COPY --from=build /build/dist/frontend /usr/share/nginx/html
 | 
			
		||||
CMD ["/bin/sh",  "-c",  "envsubst < /usr/share/nginx/html/assets/env.template.js > /usr/share/nginx/html/assets/env.js && exec nginx -g 'daemon off;'"]
 | 
			
		||||
							
								
								
									
										7
									
								
								src/assets/env.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/assets/env.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
(function(window) {
 | 
			
		||||
    window["env"] = window["env"] || {};
 | 
			
		||||
  
 | 
			
		||||
    // Environment variables
 | 
			
		||||
    window["env"]["apiUrl"] = "http://localhost:5001";
 | 
			
		||||
    window["env"]["debug"] = false;
 | 
			
		||||
  })(this);
 | 
			
		||||
							
								
								
									
										7
									
								
								src/assets/env.template.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/assets/env.template.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
(function(window) {
 | 
			
		||||
    window.env = window.env || {};
 | 
			
		||||
  
 | 
			
		||||
    // Environment variables
 | 
			
		||||
    window["env"]["apiUrl"] = "${API_URL}";
 | 
			
		||||
    window["env"]["debug"] = "${DEBUG}";
 | 
			
		||||
  })(this);
 | 
			
		||||
@@ -4,7 +4,8 @@
 | 
			
		||||
 | 
			
		||||
export const environment = {
 | 
			
		||||
  production: false,
 | 
			
		||||
  apiUrl: 'https://localhost:5001'
 | 
			
		||||
  apiUrl: window["env"]["apiUrl"] || "default",
 | 
			
		||||
  debug: window["env"]["debug"] || false
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,7 @@
 | 
			
		||||
  <base href="/">
 | 
			
		||||
  <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
			
		||||
  <link rel="icon" type="image/x-icon" href="favicon.ico">
 | 
			
		||||
  <script src="assets/env.js"></script>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
  <app-root></app-root>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user