Skip to content

Commit

Permalink
Clean up new image leftovers (#314)
Browse files Browse the repository at this point in the history
* Remove unused `.env.sample` file

* Update some comments
  • Loading branch information
dmohns authored Oct 21, 2024
1 parent b020e01 commit e6385d6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docker/DockerfileUIDev
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN npm install
COPY src/frontend .
VOLUME ["/app/"]

# serve the application
# serve the application in development mode
CMD npm run serve & tail -f /dev/null

EXPOSE 8080
8 changes: 4 additions & 4 deletions docker/DockerfileUIProd
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ WORKDIR /app
COPY src/frontend/package*.json ./
RUN npm install

# Install webserver
RUN npm install -g http-server

# get MicroPowerManager source code and configuration
COPY src/frontend .

# Copy the entrypoint script to the container and make it executable
COPY docker/entrypoint-ui-prod.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint-ui-prod.sh

# Set the entrypoint script to run when the container starts
# serve the application via entrypoint script
ENTRYPOINT ["/usr/local/bin/entrypoint-ui-prod.sh"]

# Install http-server globally
RUN npm install -g http-server

EXPOSE 8081
24 changes: 10 additions & 14 deletions docker/entrypoint-ui-prod.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
#!/bin/sh

cd /app
npm run build
# This script builds the production application at container runtime before serving it
# via webserver.
# This is enable the use of environment variables in the production container.
# As VueJS bundles the environment variables value into the application,
# see https://cli.vuejs.org/guide/mode-and-env.html#environment-variables

http-server dist -p 8081
# An alternative approach would be to use a tool like:
# https://import-meta-env.org/

cd /app
npm run build

# -----------------------------------------------------------------------------
# Dockerfile for MPM frontend production docker image
# -----------------------------------------------------------------------------
# This Dockerfile sets up the environment to build and run the frontend.
# The main objective is to create a production-ready Docker image
# that serves the frontend using http-server.
#
# The approach taken here is to use an entrypoint script as a workaround to handle
# the loading of environment variables. This ensures that any dynamic environment
# variables required at runtime are correctly
# applied before starting the server.
http-server dist -p 8081
1 change: 0 additions & 1 deletion src/frontend/.env.sample

This file was deleted.

0 comments on commit e6385d6

Please sign in to comment.