diff --git a/Dockerfile b/Dockerfile index 3e6de756..820385cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,7 @@ WORKDIR /app ARG BUILDTIME ARG VERSION ARG REVISION +ARG NEXT_PUBLIC_BASE_PATH COPY --link --from=deps /app/node_modules ./node_modules/ COPY . . @@ -30,7 +31,7 @@ COPY . . SHELL ["/bin/ash", "-xeo", "pipefail", "-c"] RUN npm run telemetry \ && 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 FROM docker.io/node:18-alpine AS runner diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh old mode 100755 new mode 100644 index c2858808..ea27aedb --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -12,6 +12,9 @@ export PGID=${PGID:-0} 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. # 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 diff --git a/next.config.js b/next.config.js index d0395611..573a6586 100644 --- a/next.config.js +++ b/next.config.js @@ -9,6 +9,7 @@ const nextConfig = { unoptimized: true, }, i18n, + basePath: process.env.NEXT_PUBLIC_BASE_PATH || '', }; module.exports = nextConfig;