Add base path support for Next.js frontend
Add support for deploying the homepage container at a specified URL path, passed as an environment variable.
This commit is contained in:
parent
cd8c224ffa
commit
9f57df4992
@ -23,6 +23,7 @@ WORKDIR /app
|
|||||||
ARG BUILDTIME
|
ARG BUILDTIME
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
ARG REVISION
|
ARG REVISION
|
||||||
|
ARG NEXT_PUBLIC_BASE_PATH
|
||||||
|
|
||||||
COPY --link --from=deps /app/node_modules ./node_modules/
|
COPY --link --from=deps /app/node_modules ./node_modules/
|
||||||
COPY . .
|
COPY . .
|
||||||
@ -30,7 +31,7 @@ COPY . .
|
|||||||
SHELL ["/bin/ash", "-xeo", "pipefail", "-c"]
|
SHELL ["/bin/ash", "-xeo", "pipefail", "-c"]
|
||||||
RUN npm run telemetry \
|
RUN npm run telemetry \
|
||||||
&& mkdir config \
|
&& mkdir config \
|
||||||
&& NEXT_PUBLIC_BUILDTIME=$BUILDTIME NEXT_PUBLIC_VERSION=$VERSION NEXT_PUBLIC_REVISION=$REVISION npm run build
|
&& NEXT_PUBLIC_BUILDTIME=$BUILDTIME NEXT_PUBLIC_VERSION=$VERSION NEXT_PUBLIC_REVISION=$REVISION NEXT_PUBLIC_BASE_PATH=$NEXT_PUBLIC_BASE_PATH npm run build
|
||||||
|
|
||||||
# Production image, copy all the files and run next
|
# Production image, copy all the files and run next
|
||||||
FROM docker.io/node:18-alpine AS runner
|
FROM docker.io/node:18-alpine AS runner
|
||||||
|
|||||||
3
docker-entrypoint.sh
Executable file → Normal file
3
docker-entrypoint.sh
Executable file → Normal file
@ -12,6 +12,9 @@ export PGID=${PGID:-0}
|
|||||||
|
|
||||||
export HOMEPAGE_BUILDTIME=$(date +%s)
|
export HOMEPAGE_BUILDTIME=$(date +%s)
|
||||||
|
|
||||||
|
# Set the base path for the Next.js application
|
||||||
|
export NEXT_PUBLIC_BASE_PATH=${NEXT_PUBLIC_BASE_PATH:-""}
|
||||||
|
|
||||||
# Set privileges for /app but only if pid 1 user is root and we are dropping privileges.
|
# Set privileges for /app but only if pid 1 user is root and we are dropping privileges.
|
||||||
# If container is run as an unprivileged user, it means owner already handled ownership setup on their own.
|
# If container is run as an unprivileged user, it means owner already handled ownership setup on their own.
|
||||||
# Running chown in that case (as non-root) will cause error
|
# Running chown in that case (as non-root) will cause error
|
||||||
|
|||||||
@ -9,6 +9,7 @@ const nextConfig = {
|
|||||||
unoptimized: true,
|
unoptimized: true,
|
||||||
},
|
},
|
||||||
i18n,
|
i18n,
|
||||||
|
basePath: process.env.NEXT_PUBLIC_BASE_PATH || '',
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = nextConfig;
|
module.exports = nextConfig;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user