Switch frontend container to production-aware runtime mode

This commit is contained in:
2026-03-02 15:41:39 -03:00
parent 0acce2e260
commit b5b74845f2
5 changed files with 30 additions and 1 deletions

View File

@@ -23,9 +23,11 @@ COPY --chown=node:node tsconfig.node.json /app/tsconfig.node.json
COPY --chown=node:node vite.config.ts /app/vite.config.ts
COPY --chown=node:node index.html /app/index.html
COPY --chown=node:node src /app/src
COPY --chown=node:node docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh
EXPOSE 5173
USER node
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "5173"]
CMD ["/app/docker-entrypoint.sh"]

View File

@@ -0,0 +1,17 @@
#!/bin/sh
# Frontend runtime entrypoint.
# Uses APP_ENV to select development or production Vite startup mode.
set -eu
APP_ENV_VALUE="${APP_ENV:-development}"
HOST_VALUE="${FRONTEND_HOST:-0.0.0.0}"
PORT_VALUE="${FRONTEND_PORT:-5173}"
if [ "$APP_ENV_VALUE" = "production" ]; then
npm run build
exec npm run preview -- --host "$HOST_VALUE" --port "$PORT_VALUE"
fi
exec npm run dev -- --host "$HOST_VALUE" --port "$PORT_VALUE"

View File

@@ -81,5 +81,10 @@ export default defineConfig(({ mode }) => {
port: 5173,
...(allowedHosts ? { allowedHosts } : {}),
},
preview: {
host: '0.0.0.0',
port: 5173,
...(allowedHosts ? { allowedHosts } : {}),
},
};
});