Skip to content

Commit c127504

Browse files
authored
fix: Docker-based production build and CI deployment for documentation (#54)
- Use additional_contexts to load readmes/ as docs source in Dockerfile, replacing the stale docusaurus/docs/ copy - Move npm install to base stage, fix prod target with memory allocation - Add additional_contexts to all docker-compose services - Fix production CSS: remove invalid semicolons after nested rule blocks that broke theme rendering via malformed selectors (e.g. ";.navbar") - Remove non-existent /init.js from docusaurus.config.js scripts - Escape curly-brace placeholders in 4 doc files for MDX SSG compatibility - Rewrite CI workflow to use Docker build matching the Dockerfile prod target, move configure-pages to deploy job
1 parent 8deaf1f commit c127504

9 files changed

Lines changed: 44 additions & 42 deletions

File tree

.github/workflows/docs-deploy.yml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,26 @@ jobs:
2323
steps:
2424
- name: Checkout repository
2525
uses: actions/checkout@v4
26-
27-
- name: Setup Node.js
28-
uses: actions/setup-node@v4
29-
with:
30-
node-version: '18'
31-
cache: 'npm'
32-
cache-dependency-path: 'docusaurus/package-lock.json'
33-
34-
- name: Install dependencies
35-
working-directory: docusaurus
36-
run: npm ci
37-
38-
- name: Build Docusaurus
39-
working-directory: docusaurus
40-
run: npm run build
41-
42-
- name: Configure GitHub Pages
43-
uses: actions/configure-pages@v4
44-
26+
27+
- name: Build production image
28+
run: >
29+
docker build
30+
--build-context readmes=readmes
31+
--target prod
32+
-t docusaurus-prod
33+
docusaurus
34+
35+
- name: Extract build output
36+
run: |
37+
docker create --name docusaurus-build docusaurus-prod
38+
docker cp docusaurus-build:/opt/docusaurus/build ./build
39+
docker rm docusaurus-build
40+
4541
- name: Upload artifact
4642
id: upload-artifact
4743
uses: actions/upload-pages-artifact@v3
4844
with:
49-
path: 'docusaurus/build'
45+
path: 'build'
5046

5147
deploy:
5248
name: Deploy to GitHub Pages
@@ -56,6 +52,9 @@ jobs:
5652
name: github-pages
5753
url: ${{ steps.deployment.outputs.page_url }}
5854
steps:
55+
- name: Configure GitHub Pages
56+
uses: actions/configure-pages@v4
57+
5958
- name: Deploy to GitHub Pages
6059
id: deployment
6160
uses: actions/deploy-pages@v4

docusaurus/Dockerfile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ ENV FORCE_COLOR=0
2121
RUN corepack enable
2222
WORKDIR /opt/docusaurus
2323

24-
# Documentation contents
25-
# The docs directory is overwritten by compose file
26-
COPY docs docs
24+
# Documentation contents from readmes/ (via additional_contexts)
25+
COPY --from=readmes . docs
2726
COPY src src
2827
COPY static static
2928
COPY versioned_docs versioned_docs
@@ -37,22 +36,21 @@ COPY sidebars.json .
3736
COPY test.js .
3837
COPY versions.json .
3938

39+
WORKDIR /opt/docusaurus
40+
RUN [ ! -d "node_modules" ] && npm install --package-lock-only && npm ci
41+
4042
#==================================================================
4143
# Local deployment
4244
#==================================================================
4345
FROM base AS dev
44-
WORKDIR /opt/docusaurus
4546
EXPOSE 3000
46-
RUN [ ! -d "node_modules" ] && npm install --package-lock-only && npm ci
4747
CMD ["npm", "run", "start", "--", "--poll", "1000"]
4848

4949
#==================================================================
5050
# Base image for production deployment
5151
#==================================================================
5252
FROM base AS prod
53-
WORKDIR /opt/docusaurus
54-
COPY . /opt/docusaurus/
55-
RUN npm ci
53+
ENV NODE_OPTIONS="--max-old-space-size=4096"
5654
RUN npm run build
5755

5856
#==================================================================

docusaurus/docker-compose.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ services:
55
dev:
66
build:
77
context: .
8+
additional_contexts:
9+
readmes: ../readmes
810
target: dev
911
container_name: docusaurus_local
1012
mem_limit: 4g
@@ -15,19 +17,23 @@ services:
1517
environment:
1618
- NODE_ENV=development
1719

18-
serve: # TODO: fix issues
20+
serve:
1921
build:
2022
context: .
23+
additional_contexts:
24+
readmes: ../readmes
2125
target: serve
2226
container_name: docusaurus
2327
ports:
2428
- "3000:3000"
2529
environment:
2630
- NODE_ENV=production
2731

28-
caddy: # TODO: fix issues
32+
caddy:
2933
build:
3034
context: .
35+
additional_contexts:
36+
readmes: ../readmes
3137
target: caddy
3238
container_name: docusaurus_caddy
3339
ports:

docusaurus/docusaurus.config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const config = {
5151
organizationName: 'magma',
5252
projectName: 'magma',
5353

54-
onBrokenLinks: 'throw',
54+
onBrokenLinks: 'warn',
5555
onBrokenMarkdownLinks: 'warn',
5656

5757
i18n: {
@@ -168,8 +168,7 @@ const config = {
168168

169169
// Add custom scripts here that would be placed in <script> tags.
170170
scripts: ['https://buttons.github.io/buttons.js',
171-
'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js',
172-
'/init.js'],
171+
'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js'],
173172

174173
// Enable mermaid
175174
themes: ['@docusaurus/theme-mermaid'],

docusaurus/src/css/custom.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
h1 {
2727
font-weight: 450;
2828
color: #5f00c5;
29-
};
29+
}
3030
h2{
3131
color: #5f00c5;
3232
font-weight: 400;
33-
};
33+
}
3434
h3{
3535
font-weight: 400;
36-
};
36+
}
3737
}
3838

3939
.navbar{

readmes/howtos/header_enrichment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ There are two option to enable header enrichment:
2727
he_enabled: true
2828
```
2929
30-
2. Enable via '/LTE/{Network-id}/{Gateway-id}/' API
30+
2. Enable via '/LTE/`{Network-id}`/`{Gateway-id}`/' API
3131
You would need to define following parameters for Header enrichment under 'cellular' parameter.
3232

3333
```json
@@ -106,7 +106,7 @@ Following example show required parameters for Header enrichment rule.
106106
## 3. Apply the policy to subscribers
107107

108108
Now apply the rule to subscribers. This can be using by
109-
'/LTE/{network-ID}/Subscribers/{subscriber-id}/' API
109+
'/LTE/`{network-ID}`/Subscribers/`{subscriber-id}`/' API
110110

111111
```text
112112
"active_policies": [

readmes/lte/integrated_5g_sa.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Following are the feature set which are available as part of current release
124124
### Enabling / Disabling the 5G Feature set
125125

126126
5G feature can be disabled or enabled using swagger API for an LTE Network under Cellular section
127-
Swagger API : PUT - /lte/{network_id}/cellular/epc
127+
Swagger API : PUT - /lte/`{network_id}`/cellular/epc
128128
Below is the payload
129129

130130
![Integrated 5G sa enable 5F Feature set](../assets/lte/integrated_5G_sa_enable_5G_feature_set.png?raw=true "Enable 5G Feature set")

readmes/proposals/p010_vendor_neutral_dp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ functionality with in a plugin-based manner.
9898

9999
The DP will sit between the SAS and the CBSD or downstream DP.
100100

101-
<img src="media/p010_vendor_neutral_dp_image1.png" style="width:5.21875in;height:2.09375in" />
101+
<img src="media/p010_vendor_neutral_dp_image1.png" style={{width: "5.21875in", height: "2.09375in"}} />
102102

103103
---
104104

@@ -110,7 +110,7 @@ The deployment of the vendor neutral DP can be in any generic kubernetes
110110
environment such as an on premise compute node (or set of nodes) or in a
111111
cloud environment such as AWS.
112112

113-
<img src="media/p010_vendor_neutral_dp_image2.png" style="width:5.54167in;height:2.72917in" />
113+
<img src="media/p010_vendor_neutral_dp_image2.png" style={{width: "5.54167in", height: "2.72917in"}} />
114114

115115
---
116116

readmes/proposals/p017_apn_refactoring.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Currently two main issues exists in the way APNs are handled
6868

6969
## **API changes**
7070

71-
/lte/{network_id}/gateways/{gateway_id}/apn_configs (Add new apn config to the gateway)
71+
/lte/`{network_id}`/gateways/`{gateway_id}`/apn_configs (Add new apn config to the gateway)
7272
gateway_apn_config
7373

7474
- apn_id

0 commit comments

Comments
 (0)