Skip to content

Commit 0be8402

Browse files
committed
Adds env variables substitution mecanism launched on container startup
1 parent ec1e6d9 commit 0be8402

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ RUN npm run build
99
# Stage 2: Serve the application with Nginx
1010
FROM nginx:1.27 as production-stage
1111
COPY --from=build-stage /app/dist /usr/share/nginx/html
12+
COPY --from=build-stage /app/dist/assets/app-config.js /usr/share/nginx/html-template/app-config.template.js
13+
COPY ./docker-entrypoint.d/*.sh /docker-entrypoint.d/
14+
RUN chmod +x /docker-entrypoint.d/*.sh
1215
EXPOSE 80
1316
CMD ["nginx", "-g", "daemon off;"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ docker build -t copilot-metrics-viewer .
138138

139139
### Docker run
140140
```
141-
docker run -p 8080:80 copilot-metrics-viewer
141+
docker run -p 8080:80 --env-file ./.env copilot-metrics-viewer
142142
```
143143
The application will be accessible at http://localhost:8080
144144

docker-entrypoint.d/99-config-app.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
configTemplateFile=/usr/share/nginx/html-template/app-config.template.js
4+
configTargetFile=/usr/share/nginx/html/assets/app-config.js
5+
6+
envsubst <"$configTemplateFile" >"$configTargetFile"

0 commit comments

Comments
 (0)