Skip to content

Commit

Permalink
add docusaurus microservice
Browse files Browse the repository at this point in the history
  • Loading branch information
cindyorangis committed Feb 2, 2022
1 parent 3311a26 commit 984b488
Show file tree
Hide file tree
Showing 48 changed files with 1,531 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ module.exports = {
plugins: ['react-native'],
rules: { 'no-use-before-define': 'off' },
},

// Docusaurus
{
files: ['src/api/docs/src/**/*.js'],
extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
plugins: ['react', 'react-hooks'],
},
],

// Default rules for any file we lint
Expand Down
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ src/api/status/public/assets
src/web/public/sw*
src/web/public/workbox*
src/api/status/src/views

# Ignore these directories for the docusaurus docs website
src/api/docs/.docusaurus
src/api/docs/build
src/api/docs/node_modules/
src/api/docs/package.json
src/api/docs/package-lock.json
11 changes: 11 additions & 0 deletions config/env.development
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ PARSER_URL=http://localhost/v1/parser
PLANET_PORT=9876


################################################################################
# Documentation Service
################################################################################

# Documentation Service Port (default is 4631)
DOCS_PORT=4631

# Documentation Service URL
DOCS_URL=http://localhost/v1/docs


################################################################################
# Telescope 1.0 Legacy Environment
################################################################################
Expand Down
11 changes: 11 additions & 0 deletions config/env.production
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ PARSER_URL=https://api.telescope.cdot.systems/v1/parser
PLANET_PORT=9876


################################################################################
# Documentation Service
################################################################################

# Documentation Service Port (default is 4631)
DOCS_PORT=4631

# Documentation Service URL
DOCS_URL=https://api.telescope.cdot.systems/v1/docs


################################################################################
# Telescope 1.0 Legacy Environment
################################################################################
Expand Down
11 changes: 11 additions & 0 deletions config/env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ PARSER_URL=https://dev.api.telescope.cdot.systems/v1/parser
PLANET_PORT=9876


################################################################################
# Documentation Service
################################################################################

# Documentation Service Port (default is 4631)
DOCS_PORT=4631

# Documentation Service URL
DOCS_URL=https://dev.api.telescope.cdot.systems/v1/docs


################################################################################
# Telescope 1.0 Legacy Environment
################################################################################
Expand Down
4 changes: 4 additions & 0 deletions docker/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,7 @@ services:
- '1111:1111'
environment:
- POSTS_URL=http://posts:5555

docs:
ports:
- '4631:4631'
25 changes: 25 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,30 @@ services:
- PLANET_PORT
- POSTS_URL

# docs service
docs:
container_name: 'docs'
build:
context: ../src/api/docs
dockerfile: Dockerfile
environment:
- NODE_ENV
- DOCS_PORT
- DOCS_URL
depends_on:
- traefik
labels:
# Enable Traefik
- 'traefik.enable=true'
# Traefik routing for the docs service at /v1/docs
- 'traefik.http.routers.docs.rule=PathPrefix(`/${API_VERSION}/docs`)'
# Specify the docs service port
- 'traefik.http.services.docs.loadbalancer.server.port=${DOCS_PORT}'
# Add middleware to this route to strip the /v1/docs prefix
- 'traefik.http.middlewares.strip_docs_prefix.stripprefix.prefixes=/${API_VERSION}/docs'
- 'traefik.http.middlewares.strip_docs_prefix.stripprefix.forceSlash=true'
- 'traefik.http.routers.docs.middlewares=strip_docs_prefix'

##############################################################################
# Third-Party Dependencies and Support Services
##############################################################################
Expand All @@ -286,6 +310,7 @@ services:
- SEARCH_URL=${SEARCH_URL}
- FEED_DISCOVERY_URL=${FEED_DISCOVERY_URL}
- STATUS_URL=${STATUS_URL}
- DOCS_URL=${DOCS_URL}
container_name: 'nginx'
environment:
- TELESCOPE_HOST
Expand Down
3 changes: 3 additions & 0 deletions docker/gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ services:
# # For development and testing, the Parser service needs to contact the users
# # service directly via Docker vs through the http://localhost domain.
# - USERS_URL=http://users:7000

docs:
ports: '4631:4631'
5 changes: 5 additions & 0 deletions docker/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ services:
- FEED_QUEUE_PARALLEL_WORKERS
- MAX_POSTS_PER_PAGE
- GIT_COMMIT
- DOCS_URL
depends_on:
- redis
- elasticsearch
Expand Down Expand Up @@ -122,6 +123,10 @@ services:
- ELASTIC_URL=http://elasticsearch
- ELASTIC_PORT=9200

# docs service
docs:
restart: unless-stopped

##############################################################################
# Third-Party Dependencies and Support Services
##############################################################################
Expand Down
20 changes: 20 additions & 0 deletions src/api/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
27 changes: 27 additions & 0 deletions src/api/docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## 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 package.json and lock file over
COPY package*.json /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
# Copy the source code over
COPY --chown=node:node . /home/node/app/
# Switch to the node user vs. root
USER node
# Expose port 4631
EXPOSE 4631
# Start the app in debug mode so we can attach the debugger
CMD ["npm", "run", "start"]
41 changes: 41 additions & 0 deletions src/api/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Website

This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.

### Installation

```
$ yarn
```

### Local Development

```
$ yarn start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Deployment

Using SSH:

```
$ USE_SSH=true yarn deploy
```

Not using SSH:

```
$ GIT_USER=<Your GitHub username> yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
3 changes: 3 additions & 0 deletions src/api/docs/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
12 changes: 12 additions & 0 deletions src/api/docs/blog/2019-05-28-first-blog-post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
slug: first-blog-post
title: First Blog Post
authors:
name: Gao Wei
title: Docusaurus Core Team
url: https://github.com/wgao19
image_url: https://github.com/wgao19.png
tags: [hola, docusaurus]
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
44 changes: 44 additions & 0 deletions src/api/docs/blog/2019-05-29-long-blog-post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
slug: long-blog-post
title: Long Blog Post
authors: endi
tags: [hello, docusaurus]
---

This is the summary of a very long blog post,

Use a `<!--` `truncate` `-->` comment to limit blog post size in the list view.

<!--truncate-->

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
20 changes: 20 additions & 0 deletions src/api/docs/blog/2021-08-01-mdx-blog-post.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
slug: mdx-blog-post
title: MDX Blog Post
authors: [slorber]
tags: [docusaurus]
---

Blog posts support [Docusaurus Markdown features](https://docusaurus.io/docs/markdown-features), such as [MDX](https://mdxjs.com/).

:::tip

Use the power of React to create interactive blog posts.

```js
<button onClick={() => alert('button clicked!')}>Click me!</button>
```

<button onClick={() => alert('button clicked!')}>Click me!</button>

:::
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/api/docs/blog/2021-08-26-welcome/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
slug: welcome
title: Welcome
authors: [slorber, yangshun]
tags: [facebook, hello, docusaurus]
---

[Docusaurus blogging features](https://docusaurus.io/docs/blog) are powered by the [blog plugin](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog).

Simply add Markdown files (or folders) to the `blog` directory.

Regular blog authors can be added to `authors.yml`.

The blog post date can be extracted from filenames, such as:

- `2019-05-30-welcome.md`
- `2019-05-30-welcome/index.md`

A blog post folder can be convenient to co-locate blog post images:

![Docusaurus Plushie](./docusaurus-plushie-banner.jpeg)

The blog supports tags as well!

**And if you don't want a blog**: just delete this directory, and use `blog: false` in your Docusaurus config.
17 changes: 17 additions & 0 deletions src/api/docs/blog/authors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
endi:
name: Endilie Yacop Sucipto
title: Maintainer of Docusaurus
url: https://github.com/endiliey
image_url: https://github.com/endiliey.png

yangshun:
name: Yangshun Tay
title: Front End Engineer @ Facebook
url: https://github.com/yangshun
image_url: https://github.com/yangshun.png

slorber:
name: Sébastien Lorber
title: Docusaurus maintainer
url: https://sebastienlorber.com
image_url: https://github.com/slorber.png
Loading

0 comments on commit 984b488

Please sign in to comment.