Skip to content

Commit 7123bce

Browse files
Containerized build (#419)
* Enable containerized build. * Remove obsolete pre-render package * Fix React rendering violations. * Update readme * Adjust package-lock * Add eslint plugin * Add prettier task and run it --------- Co-authored-by: Martin Marosi <[email protected]>
1 parent cdda238 commit 7123bce

File tree

98 files changed

+6487
-3895
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+6487
-3895
lines changed

.eslintrc.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"extends": ["eslint:recommended", "plugin:react/recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended", "prettier"],
4+
"plugins": ["prettier", "@typescript-eslint"],
5+
"parserOptions": {
6+
"ecmaVersion": 6,
7+
"sourceType": "module",
8+
"ecmaFeatures": {
9+
"jsx": true,
10+
"modules": true,
11+
"experimentalObjectRestSpread": true
12+
}
13+
},
14+
"settings": {
15+
"react": {
16+
"version": "16.6"
17+
}
18+
},
19+
"rules": {
20+
"react/react-in-jsx-scope": "off",
21+
"typescript-eslint/no-non-null-asserted-optional-chain": "off"
22+
}
23+
}

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ public/canonical.json
3636

3737
# rollup
3838
.rollup.cache
39+
# next
40+
.next
41+
next-env.d.ts
42+
out
43+

Dockerfile

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ USER root
44

55
WORKDIR /usr/share/builder
66

7-
COPY package.json package-lock.json tsconfig.json config-overrides.js ./
7+
COPY package.json package-lock.json tsconfig.json next.config.ts .eslintrc.json prettier.config.js proxy.mjs ./
88
COPY src ./src
99
COPY public ./public
10-
COPY packages/common ./packages/common
10+
COPY packages ./packages
1111

1212
RUN npm i
13+
RUN npm run build
1314

1415
FROM registry.access.redhat.com/ubi9/nginx-124
1516

1617
WORKDIR /usr/share/nginx
1718

18-
COPY --from=builder /usr/share/builder/ /usr/share/nginx/html
19+
COPY --from=builder /usr/share/builder/out /usr/share/nginx/html
1920
COPY nginx.conf /etc/nginx/nginx.conf
2021

2122
EXPOSE 8080

README.md

+7-11
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ https://developers.redhat.com/api-catalog/
66

77
## Project structure
88

9-
The main package is found on [src](./src) and contains the React application for the site itself.
9+
The main package is found on [src](./src) and contains the Next.js application.
1010

1111
Other packages includes:
1212
- [Common code](./packages/common) shared across other packages. Contains the information about the included APIs.
1313
- [Discovery](./packages/discovery) contains a file descriptor and its supporting schemas to describe the contents
1414
found in API catalog. It includes the list of the APIs, what group they form part of and their metadata.
15-
- [Prerender](./packages/prerender) is a cli tool to pre-render all the API catalog to increase SEO and make it easier to
16-
be read by bots.
1715
- [Sitemap](./packages/sitemap) is a cli tool to create the sitemap.xml of API catalog. The sitemap package is also responsible for generating the [canonical format json file](./public/canonical.json) used by the Search Platform for indexing.
1816
- [transform](./packages/transform) is a cli tool to process the [discovery file](./packages/discovery/Discovery.yml)
1917
and create typescript code that can be loaded by API Catalog, the resulting code is stored in the
@@ -78,7 +76,7 @@ Use `npm install` to install all the project dependencies.
7876

7977
### Running the frontend
8078

81-
Use `npm run start` to start the frontend application.
79+
Use `npm run dev` to start the frontend application.
8280

8381
### Running the discovery process
8482

@@ -92,12 +90,6 @@ npm run discovery:build && npm run discovery:start -- --skip-api-fetch
9290

9391
The sitemap can be re-generated by running: `SITEMAP_BASE_URL=https://my-base-url npm run sitemap`.
9492

95-
### Pre-rendering the site
96-
97-
To be more bot-friendly we pre-render the whole site to allow it to be crawled.
98-
You can run trigger a local run by building the site `npm run build` and then running `npm run prerender`. The results of the pre-rendering are written in
99-
[build/pre-rendered](./build/pre-rendered)
100-
10193
## Adding external content
10294

10395
Details from each API is extracted from its openapi file to show in the API catalog. Sometimes this is not enough.
@@ -125,7 +117,7 @@ This is a list of the support sections, followed by the required file name.
125117

126118
- Getting started: `getting-started.md`
127119

128-
## Releasing to Production
120+
## Releasing to Production (Deprecated)
129121

130122
We use GitLab tags for deployment to Production. Follow these steps:
131123

@@ -150,6 +142,10 @@ We use GitLab tags for deployment to Production. Follow these steps:
150142

151143
4. **Watch the pipeline:** Monitor the pipeline in GitLab's CI/CD > Pipelines section. If successful, your code is deployed to production.
152144

145+
## Releasing to production (new)
146+
147+
TBD
148+
153149
## SPAship configuration
154150

155151
We require some components that are shared across developers.redhat.com (header and footer). These components needs to be copied (and synchronized from time to time).

next.config.ts

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { NextConfig } from 'next';
2+
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';
3+
4+
const nextConfig: NextConfig = {
5+
/* config options here */
6+
output: 'export',
7+
images: {
8+
unoptimized: true,
9+
},
10+
...(process.env.DEV === 'true'
11+
? {
12+
async rewrites() {
13+
// proxy to get the assets from developers.redhat.com
14+
return [
15+
{
16+
source: '/modules/:path*',
17+
destination: 'http://localhost:3001/modules/:path*',
18+
},
19+
];
20+
},
21+
basePath: '',
22+
}
23+
: {
24+
basePath: '/api-catalog',
25+
}),
26+
webpack: (config, { isServer }) => {
27+
if (!isServer) {
28+
config.plugins.push(
29+
new MonacoWebpackPlugin({
30+
languages: ['go', 'python', 'java', 'javascript', 'shell', 'cpp', 'ruby', 'json'],
31+
filename: 'static/[name].worker.js',
32+
}),
33+
);
34+
}
35+
return config;
36+
},
37+
};
38+
39+
export default nextConfig;

0 commit comments

Comments
 (0)