chore: Refactor Dockerfile and update HTML favicon links
- Simplify Dockerfile by removing redundant BASE_URL handling logic and complex RUN commands - Change SIMPLE_MODE default from true to false for production builds - Fix indentation inconsistencies in Dockerfile conditional statements - Move favicon link tags from body to head section in all HTML files for proper semantic structure - Replace inline favicon links with img tag in navigation logo across all pages - Update README.md documentation to clarify BASE_URL trailing slash requirements - Remove commented-out legacy Dockerfile code for cleaner maintenance - Consolidate favicon declarations in document head for better performance and SEO
This commit is contained in:
68
Dockerfile
68
Dockerfile
@@ -1,5 +1,5 @@
|
||||
# global variable declaration:
|
||||
# -Build to serve under Subdirectory BASE_URL if provided, eg: "ARG BASE_URL=/pdf/", otherwise leave blank: "ARG BASE_URL="
|
||||
# Global variable declaration:
|
||||
# Build to serve under Subdirectory BASE_URL if provided, eg: "ARG BASE_URL=/pdf/", otherwise leave blank: "ARG BASE_URL="
|
||||
ARG BASE_URL=
|
||||
|
||||
# Build stage
|
||||
@@ -11,7 +11,7 @@ COPY . .
|
||||
|
||||
# Build without type checking (vite build only)
|
||||
# Pass SIMPLE_MODE environment variable if provided
|
||||
ARG SIMPLE_MODE=true
|
||||
ARG SIMPLE_MODE=false
|
||||
ENV SIMPLE_MODE=$SIMPLE_MODE
|
||||
|
||||
# global arg to local arg
|
||||
@@ -19,9 +19,9 @@ ARG BASE_URL
|
||||
ENV BASE_URL=$BASE_URL
|
||||
|
||||
RUN if [ -z "$BASE_URL" ]; then \
|
||||
npm run build -- --mode production; \
|
||||
npm run build -- --mode production; \
|
||||
else \
|
||||
npm run build -- --base=${BASE_URL} --mode production; \
|
||||
npm run build -- --base=${BASE_URL} --mode production; \
|
||||
fi
|
||||
|
||||
# Production stage
|
||||
@@ -34,65 +34,7 @@ ARG BASE_URL
|
||||
|
||||
COPY --chown=nginx:nginx --from=builder /app/dist /usr/share/nginx/html${BASE_URL%/}
|
||||
COPY --chown=nginx:nginx nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
RUN set -e; \
|
||||
SUBDIR=$(echo "${BASE_URL}" | sed 's:^/::; s:/$::'); \
|
||||
if [ -z "${SUBDIR}" ] || [ "${SUBDIR}" = "/" ]; then \
|
||||
DEST_DIR="/usr/share/nginx/html"; \
|
||||
else \
|
||||
DEST_DIR="/usr/share/nginx/html/${SUBDIR}"; \
|
||||
mkdir -p "${DEST_DIR}"; \
|
||||
fi; \
|
||||
chown -R nginx:nginx /usr/share/nginx/html; \
|
||||
echo "Destination directory: ${DEST_DIR}"
|
||||
|
||||
COPY --chown=nginx:nginx --from=builder /app/dist /tmp/dist
|
||||
|
||||
RUN set -e; \
|
||||
SUBDIR=$(echo "${BASE_URL}" | sed 's:^/::; s:/$::'); \
|
||||
if [ -z "${SUBDIR}" ] || [ "${SUBDIR}" = "/" ]; then \
|
||||
DEST_DIR="/usr/share/nginx/html"; \
|
||||
else \
|
||||
DEST_DIR="/usr/share/nginx/html/${SUBDIR}"; \
|
||||
fi; \
|
||||
cp -r /tmp/dist/* "${DEST_DIR}/"; \
|
||||
rm -rf /tmp/dist; \
|
||||
chown -R nginx:nginx /usr/share/nginx/html; \
|
||||
echo "Files copied to: ${DEST_DIR}"; \
|
||||
ls -la "${DEST_DIR}" | head -20
|
||||
|
||||
RUN mkdir -p /etc/nginx/tmp && chown -R nginx:nginx /etc/nginx/tmp
|
||||
|
||||
USER nginx
|
||||
|
||||
EXPOSE 8080
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
|
||||
|
||||
# Old Dockerfile for Root User
|
||||
# # Build stage
|
||||
# FROM node:20-alpine AS builder
|
||||
|
||||
# WORKDIR /app
|
||||
|
||||
# COPY package*.json ./
|
||||
# RUN npm ci
|
||||
|
||||
# COPY . .
|
||||
|
||||
# # Build without type checking (vite build only)
|
||||
# # Pass SIMPLE_MODE environment variable if provided
|
||||
# ARG SIMPLE_MODE=false
|
||||
# ENV SIMPLE_MODE=$SIMPLE_MODE
|
||||
# RUN npm run build -- --mode production
|
||||
|
||||
# # Production stage
|
||||
# FROM nginx:alpine
|
||||
|
||||
# COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
# COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# EXPOSE 8080
|
||||
|
||||
# CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
Reference in New Issue
Block a user