From bcd2106ad07f0e3937336102107c8133ce1535b0 Mon Sep 17 00:00:00 2001 From: Kyriakos Akriotis Date: Sun, 30 Jun 2024 23:14:31 +0200 Subject: [PATCH] containirize and env vars in config.ts --- Dockerfile | 2 +- Dockerfile2 | 40 ++++++++++++++++++++++++++++++++ docker-compose.debug.yml | 14 +++++++++++ docker-compose.yml | 12 ++++++++++ docusaurus.config.ts | 50 +++++++++++++++++++++++++++++++++++----- package.json | 4 ++-- 6 files changed, 113 insertions(+), 9 deletions(-) create mode 100644 Dockerfile2 create mode 100644 docker-compose.debug.yml create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index c27f02084..8fbfef4e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ COPY package*.json ./ RUN npm install COPY . . -EXPOSE 3000 +EXPOSE 80 CMD ["npm", "start"] diff --git a/Dockerfile2 b/Dockerfile2 new file mode 100644 index 000000000..b503d0a0e --- /dev/null +++ b/Dockerfile2 @@ -0,0 +1,40 @@ +## Base ######################################################################## +# Use a larger node image to do the build for native deps (e.g., gcc, python) +FROM node:lts as base + +# Reduce npm log spam and colour during install within Docker +ENV NPM_CONFIG_LOGLEVEL=warn +ENV NPM_CONFIG_COLOR=false + +# We'll run the app as the `node` user, so put it in their home directory +WORKDIR /home/node/app +# Copy the source code over +COPY --chown=node:node . /home/node/app/ + +## Development ################################################################# +# Define a development target that installs devDeps and runs in dev mode +FROM base as development +WORKDIR /home/node/app +# Install (not ci) with dependencies, and for Linux vs. Linux Musl (which we use for -alpine) +RUN npm install +# Switch to the node user vs. root +USER node +# Expose port 3000 +EXPOSE 3000 +# Start the app in debug mode so we can attach the debugger +CMD ["npm", "start"] + +## Production ################################################################## +# Also define a production target which doesn't use devDeps +FROM base as production +WORKDIR /home/node/app +COPY --chown=node:node --from=development /home/node/app/node_modules /home/node/app/node_modules +# Build the Docusaurus app +RUN npm run build + +## Deploy ###################################################################### +# Use a stable nginx image +FROM nginx:stable-alpine as deploy +WORKDIR /home/node/app +# Copy what we've installed/built from production +COPY --chown=node:node --from=production /home/node/app/build /usr/share/nginx/html/ \ No newline at end of file diff --git a/docker-compose.debug.yml b/docker-compose.debug.yml new file mode 100644 index 000000000..00dec067c --- /dev/null +++ b/docker-compose.debug.yml @@ -0,0 +1,14 @@ +version: '3.4' + +services: + docsnext: + image: docsnext + build: + context: . + dockerfile: ./Dockerfile + environment: + NODE_ENV: development + ports: + - 3000:3000 + - 9229:9229 + command: ["node", "--inspect=0.0.0.0:9229", "index.js"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..f6ef16883 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.4' + +services: + docsnext: + image: docsnext + build: + context: . + dockerfile: ./Dockerfile + environment: + NODE_ENV: production + ports: + - 3000:3000 diff --git a/docusaurus.config.ts b/docusaurus.config.ts index a978981cf..14d54075d 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -8,7 +8,7 @@ const config: Config = { favicon: 'img/favicon.ico', // Set the production url of your site here - url: 'https://your-docusaurus-site.example.com', + url: 'https://blueprints.hypelens.de', // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' baseUrl: '/', @@ -17,6 +17,7 @@ const config: Config = { // If you aren't using GitHub pages, you don't need these. organizationName: 'akyriako', // Usually your GitHub org/user name. projectName: 'docs-next', // Usually your repo name. + deploymentBranch: 'gh-pages', onBrokenLinks: 'throw', onBrokenMarkdownLinks: 'warn', @@ -85,7 +86,7 @@ const config: Config = { // }, // { to: '/blog', label: 'Blog', position: 'right' }, { href: 'https://auth.otc.t-systems.com/', label: 'Console', position: 'right' }, - // { href: 'https://github.com/akyriako/docs-next', label: 'GitHub', position: 'right',}, + { href: 'https://github.com/akyriako/docs-next', label: 'GitHub', position: 'right',}, ], }, footer: { @@ -172,6 +173,43 @@ const config: Config = { autoCollapseCategories: true, }, }, + // typesense: { + // // Replace this with the name of your index/collection. + // // It should match the "index_name" entry in the scraper's "config.json" file. + // typesenseCollectionName: 'docs-next', + // typesenseServerConfig: { + // nearestNode: { + // host: 'typesense-headless.typesense.svc.cluster.local', + // port: 8108, + // protocol: 'http', + // }, + // nodes: [ + // { + // host: 'typesense-0.typesense-headless.typesense.svc.cluster.local', + // port: 8108, + // protocol: 'http', + // }, + // { + // host: 'typesense-1.typesense-headless.typesense.svc.cluster.local', + // port: 8108, + // protocol: 'http', + // }, + // { + // host: 'typesense-2.typesense-headless.typesense.svc.cluster.local', + // port: 8108, + // protocol: 'http', + // }, + // ], + // apiKey: 'Mycomplexpassword#6546', + // }, + + // // Optional: Typesense search parameters: https://typesense.org/docs/0.24.0/api/search.html#search-parameters + // typesenseSearchParameters: {}, + + // // Optional + // contextualSearch: true, + // }, + typesense: { // Replace this with the name of your index/collection. // It should match the "index_name" entry in the scraper's "config.json" file. @@ -180,12 +218,12 @@ const config: Config = { typesenseServerConfig: { nodes: [ { - host: 'typesense-headless', - port: 8108, - protocol: 'http', + host: process.env.TYPESENSE_HOST, + port: process.env.TYPESENSE_PORT, + protocol: process.env.TYPESENSE_PROTOCOL, }, ], - apiKey: 'Mycomplexpassword#6546', + apiKey: process.env.TYPESENSE_API_KEY, }, // Optional: Typesense search parameters: https://typesense.org/docs/0.24.0/api/search.html#search-parameters diff --git a/package.json b/package.json index 9db358400..d54ceed9a 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,12 @@ "private": true, "scripts": { "docusaurus": "docusaurus", - "start": "docusaurus start --host 0.0.0.0", + "start": "docusaurus start --host 0.0.0.0 --port 80", "build": "docusaurus build", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", "clear": "docusaurus clear", - "serve": "docusaurus serve --host 0.0.0.0", + "serve": "docusaurus serve --host 0.0.0.0 --port 80", "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", "typecheck": "tsc"