Added BASE_URL support to the Dockerfile
This commit is contained in:
23
Dockerfile
23
Dockerfile
@@ -1,3 +1,7 @@
|
|||||||
|
# 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
|
# Build stage
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -7,16 +11,28 @@ COPY . .
|
|||||||
|
|
||||||
# Build without type checking (vite build only)
|
# Build without type checking (vite build only)
|
||||||
# Pass SIMPLE_MODE environment variable if provided
|
# Pass SIMPLE_MODE environment variable if provided
|
||||||
ARG SIMPLE_MODE=false
|
ARG SIMPLE_MODE=true
|
||||||
ENV SIMPLE_MODE=$SIMPLE_MODE
|
ENV SIMPLE_MODE=$SIMPLE_MODE
|
||||||
RUN npm run build -- --mode production
|
|
||||||
|
# global arg to local arg
|
||||||
|
ARG BASE_URL
|
||||||
|
ENV BASE_URL=$BASE_URL
|
||||||
|
|
||||||
|
RUN if [ -z "$BASE_URL" ]; then \
|
||||||
|
npm run build -- --mode production; \
|
||||||
|
else \
|
||||||
|
npm run build -- --base=${BASE_URL} --mode production; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Production stage
|
# Production stage
|
||||||
FROM nginxinc/nginx-unprivileged:stable-alpine-slim
|
FROM nginxinc/nginx-unprivileged:stable-alpine-slim
|
||||||
|
|
||||||
LABEL org.opencontainers.image.source="https://github.com/alam00000/bentopdf"
|
LABEL org.opencontainers.image.source="https://github.com/alam00000/bentopdf"
|
||||||
|
|
||||||
COPY --chown=nginx:nginx --from=builder /app/dist /usr/share/nginx/html
|
# global arg to local arg
|
||||||
|
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
|
COPY --chown=nginx:nginx nginx.conf /etc/nginx/nginx.conf
|
||||||
RUN mkdir -p /etc/nginx/tmp && chown -R nginx:nginx /etc/nginx/tmp
|
RUN mkdir -p /etc/nginx/tmp && chown -R nginx:nginx /etc/nginx/tmp
|
||||||
|
|
||||||
@@ -24,6 +40,7 @@ EXPOSE 8080
|
|||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Old Dockerfile for Root User
|
# Old Dockerfile for Root User
|
||||||
# # Build stage
|
# # Build stage
|
||||||
# FROM node:20-alpine AS builder
|
# FROM node:20-alpine AS builder
|
||||||
|
|||||||
Reference in New Issue
Block a user