mirror of
https://github.com/netbirdio/docs.git
synced 2026-04-16 07:26:35 +00:00
Enable algolia search
This commit is contained in:
3
.env
Normal file
3
.env
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
NEXT_PUBLIC_DOCSEARCH_APP_ID=APP_NEXT_PUBLIC_DOCSEARCH_APP_ID
|
||||||
|
NEXT_PUBLIC_DOCSEARCH_API_KEY=APP_NEXT_PUBLIC_DOCSEARCH_API_KEY
|
||||||
|
NEXT_PUBLIC_DOCSEARCH_INDEX_NAME=APP_NEXT_PUBLIC_DOCSEARCH_INDEX_NAME
|
||||||
@@ -16,15 +16,17 @@ RUN npm install --production
|
|||||||
# Copy all files
|
# Copy all files
|
||||||
COPY ./ ./
|
COPY ./ ./
|
||||||
|
|
||||||
|
COPY /docker/entrypoint.sh ./entrypoint.sh
|
||||||
|
|
||||||
# Build app
|
# Build app
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
RUN chmod u+x /usr/app/entrypoint.sh
|
||||||
|
|
||||||
# Expose the listening port
|
# Expose the listening port
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Run container as non-root (unprivileged) user
|
# apply env variables to the Nextjs .env file
|
||||||
# The node user is provided in the Node.js Alpine base image
|
ENTRYPOINT ["/usr/app/entrypoint.sh"]
|
||||||
USER node
|
|
||||||
|
|
||||||
# Run npm start script with PM2 when container starts
|
CMD npm run start
|
||||||
CMD [ "pm2-runtime", "npm", "--", "start" ]
|
|
||||||
17
docker/entrypoint.sh
Normal file
17
docker/entrypoint.sh
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# this script will check for the following NEXT_* environment variables passed via Docker environment (-e) and apply them
|
||||||
|
# to the Nextjs.
|
||||||
|
# The properties that will be replaced and have to start with APP_ prefix in the .env file
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
NEXT_PUBLIC_DOCSEARCH_APP_ID=${NEXT_PUBLIC_DOCSEARCH_APP_ID:-"none"}
|
||||||
|
NEXT_PUBLIC_DOCSEARCH_API_KEY=${NEXT_PUBLIC_DOCSEARCH_API_KEY:-"none"}
|
||||||
|
NEXT_PUBLIC_DOCSEARCH_INDEX_NAME=${NEXT_PUBLIC_DOCSEARCH_INDEX_NAME:"none"}
|
||||||
|
|
||||||
|
find /usr/app/.next \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s#APP_NEXT_PUBLIC_DOCSEARCH_APP_ID#${NEXT_PUBLIC_DOCSEARCH_APP_ID}#g"
|
||||||
|
find /usr/app/.next \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s#APP_NEXT_PUBLIC_DOCSEARCH_API_KEY#${NEXT_PUBLIC_DOCSEARCH_API_KEY}#g"
|
||||||
|
find /usr/app/.next \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s#APP_NEXT_PUBLIC_DOCSEARCH_INDEX_NAME#${NEXT_PUBLIC_DOCSEARCH_INDEX_NAME}#g"
|
||||||
|
|
||||||
|
echo "starting Nextjs"
|
||||||
|
exec "$@"
|
||||||
Reference in New Issue
Block a user