Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Zilliqa/dev-portal
Browse files Browse the repository at this point in the history
  • Loading branch information
ziaddarwishcreoshift committed Sep 11, 2024
2 parents 4b0c528 + 0e6d4f2 commit 7ee2cb0
Show file tree
Hide file tree
Showing 195 changed files with 1,598 additions and 471 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/cicd-prd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
env:
ENVIRONMENT: prd
IMAGE_TAG: ${{ steps.set-tag.outputs.tags }}
ZQ2: 0
run: |
cd ${{ matrix.path }}
make image/build-and-push
Expand All @@ -78,6 +79,7 @@ jobs:
IMAGE_TAG: ${{ env.REGISTRY }}/${{ matrix.image_name }}:${{ github.ref_name }}
ENV_FILES_DECRYPTER_NONPRD: ${{ secrets.ENV_FILES_DECRYPTER_NONPRD }}
ENV_FILES_DECRYPTER_PRD: ${{ secrets.ENV_FILES_DECRYPTER_PRD }}
ZQ2: 0
run: |
cd ${{ matrix.path }}
make image/build-and-push
Expand All @@ -89,6 +91,7 @@ jobs:
IMAGE_TAG: ${{ env.REGISTRY }}/${{ matrix.image_name }}:latest
ENV_FILES_DECRYPTER_NONPRD: ${{ secrets.ENV_FILES_DECRYPTER_NONPRD }}
ENV_FILES_DECRYPTER_PRD: ${{ secrets.ENV_FILES_DECRYPTER_PRD }}
ZQ2: 0
run: |
cd ${{ matrix.path }}
make image/build-and-push
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/cicd-stg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
env:
ENVIRONMENT: stg
IMAGE_TAG: ${{ steps.set-tag.outputs.tags }}
ZQ2: 1
run: |
cd ${{ matrix.path }}
make image/build-and-push
Expand All @@ -79,6 +80,7 @@ jobs:
env:
ENVIRONMENT: stg
IMAGE_TAG: "${{ env.REGISTRY }}/${{ matrix.image_name }}:latest"
ZQ2: 1
run: |
cd ${{ matrix.path }}
make image/build-and-push
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ target/
cache/**
!cache/.gitkeep
# Used for rendering API docs.
zq2/docs/apis/**
zq2/docs/api/**
docgen/target
36 changes: 22 additions & 14 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.22.1
version: 1.22.3
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.5.0
ref: v1.6.2
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
Expand All @@ -17,22 +17,25 @@ runtimes:
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- markdownlint@0.40.0
- osv-scanner@1.7.3
- [email protected].1
- prettier@3.2.5
- ruff@0.4.4
- markdownlint@0.41.0
- osv-scanner@1.8.4
- [email protected].2
- prettier@3.3.3
- ruff@0.6.2
- [email protected]
- trivy@0.51.2
- trufflehog@3.76.3
- trivy@0.54.1
- trufflehog@3.81.9
- [email protected]
ignore:
- linters: [gitleaks]
Expand All @@ -47,6 +50,7 @@ lint:
- zq1/docs/exchanges
- linters: [markdownlint]
paths:
- zq1/** # Not worth fixing.
- zq2/docs/ecosystem/index.md # multiple headers
- zq2/docs/zilevm/tools/remix.md # Don't care about line length
- README.md
Expand All @@ -58,7 +62,11 @@ lint:
- Dockerfile # Annoying, but trunk is now very opinionated on how you write dockerfiles.
- zq2/docs/js/** # trunk does not know this is looking for metamask in the user's browser.
- zq2/docs/index.md # contains legitimate empty links
- zq2/docs/nodes/**
- .trunk/*out/**
- cd/base/deployment.yaml
- zq1/** # Legacy


actions:
enabled:
Expand Down
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{
}
{}
26 changes: 20 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,43 @@ ENV NEEDRESTART_MODE=a
RUN apt-get update && apt-get dist-upgrade -y
RUN apt-get install -y python3 python3-pip python3-setuptools --no-install-recommends
RUN apt-get install -y protobuf-compiler build-essential libssl-dev pkg-config git cmake
RUN apt autoremove
RUN apt-get autoremove

COPY . /build
# Nonsensical, but allows us to cache requirements.
RUN mkdir /build
COPY requirements.txt /build/requirements.txt
RUN pip3 install --no-cache-dir -r /build/requirements.txt

COPY . /build

ENV DOC_SOURCE=docs
WORKDIR /build/zq1
RUN mkdocs build
WORKDIR /build/docgen
RUN cargo run /build
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/build/docgen/target \
--mount=type=cache,target=/build/cache/zq2 \
cargo run /build

WORKDIR /build/zq2
ARG VERSION
ENV VERSION=$VERSION
RUN mkdocs build

ARG ZQ2
ENV ZQ2=$ZQ2
WORKDIR /build/zq1
RUN if [ "$ZQ2" -eq 0 ]; then mkdocs build -f mkdocs.nozq2.yml; else mkdocs build -f mkdocs.zq2.yml; fi

FROM nginx:alpine-slim

RUN mkdir -p /usr/share/nginx/html/zilliqa1
RUN mkdir -p /usr/share/nginx/html/zilliqa2
COPY --from=builder --chown=nginx:nginx /build/zq1/site/. /usr/share/nginx/html/zilliqa1/.
COPY --from=builder --chown=nginx:nginx /build/zq2/site/. /usr/share/nginx/html/zilliqa2/.
COPY default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
COPY default.nozq2.conf /etc/nginx/conf.d/default.nozq2.conf
ARG ZQ2
ENV ZQ2=$ZQ2
RUN if [ "$ZQ2" -eq 0 ]; then rm -rf /usr/share/nginx/html/zilliqa2 && mv /etc/nginx/conf.d/default.nozq2.conf /etc/nginx/conf.d/default.conf; else rm /etc/nginx/conf.d/default.nozq2.conf; fi

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
28 changes: 22 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ zq2/docs/mkdocs.yml autogen:
(cd $(HERE)/docgen && cargo run $(HERE))

dev1:
(cd zq1 && DOC_SOURCE=$(HERE)/zq1/docs mkdocs serve $(SERVEOPTS))
(cd zq1 && DOC_SOURCE=$(HERE)/zq1/docs mkdocs serve -f mkdocs.zq2.yml $(SERVEOPTS))

dev1nozq2:
(cd zq1 && DOC_SOURCE=$(HERE)/zq1/docs mkdocs serve -f mkdocs.nozq2.yml $(SERVEOPTS))

dev2: zq2/docs/mkdocs.yml
(cd zq2 && DOC_SOURCE=$(HERE)/zq2/docs mkdocs serve $(SERVEOPTS))
Expand All @@ -45,20 +48,33 @@ assemble:
cp -r $(HERE)/zq2 $(BINDIR)

IMAGE_TAG ?= developer-portal:latest
IMAGE_TAG_NOZQ2 ?= developer-portal-nozq2:latest
ZQ2 ?= 1

build:
docker buildx build --build-arg VERSION="${VERSION}" . -t $(IMAGE_TAG)
docker buildx build --build-arg ZQ2=1 --build-arg VERSION="${VERSION}" -f Dockerfile . -t $(IMAGE_TAG)
docker buildx build --build-arg ZQ2=0 --build-arg VERSION="${VERSION}" -f Dockerfile . -t $(IMAGE_TAG_NOZQ2)


run-image: build
docker run --rm -p 8080:80 "$(IMAGE_TAG)"

STG_TAG=asia-docker.pkg.dev/prj-d-dev-apps-n3p4o97j/zilliqa/developer-portal
run-image-nozq2: build
docker run --rm -p 8080:80 "$(IMAGE_TAG_NOZQ2)"

DEV_TAG=asia-docker.pkg.dev/prj-d-dev-apps-n3p4o97j/zilliqa/developer-portal
DEV_TAG_NOZQ2=$(DEV_TAG)-nozq2
## Push to the dev repo so you can check that the docker container actually works ..
push-dev-image: build
docker tag "${IMAGE_TAG}" "${STG_TAG}"
docker push "${STG_TAG}"
docker tag "${IMAGE_TAG}" "${DEV_TAG}:latest"
docker push "${DEV_TAG}"

push-dev-image-nozq2: build
docker tag "${IMAGE_TAG_NOZQ2}" "${DEV_TAG}:latest"
docker push "${DEV_TAG}"
echo Now restart the pod ..

## Build and push the Docker image
image/build-and-push: build
image/build-and-push:
docker buildx build --build-arg ZQ2=$(ZQ2) --build-arg VERSION="${VERSION}" -f Dockerfile . -t $(IMAGE_TAG)
docker push "$(IMAGE_TAG)"
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ config file from `default.conf`.
The material theme is fairly heavily customised with overrides in both
Zilliqa 1 and Zilliqa 2.

There are two versions of the Zilliqa 1 documentation - regular, and
without the zq2 documentation (`nozq2`); the switch is made by
substituting the relevant `mkdocs.yaml` file from the `zq1/`
directory.

## Docgen

The `docgen` program:
Expand Down Expand Up @@ -62,6 +67,7 @@ repository](https://github.com/zilliqa/zq2) for details.
Now,

- `make dev1` will make and serve the ZQ1 docs locally on port 8000.
- `make dev1nozq2` will make and serve the ZQ1 docs (with no ZQ2 reference) locally on port 8000
- `make dev2` will do the same with the ZQ2 docs.

You can set `SERVEROPTS` to pass option (usually `-a
Expand Down
2 changes: 1 addition & 1 deletion cd/base/backend-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ metadata:
spec:
timeoutSec: 120
healthCheck:
requestPath: /zilliqa2/
requestPath: /health
2 changes: 1 addition & 1 deletion cd/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ spec:
memory: 100Mi
readinessProbe:
httpGet:
path: /zilliqa2/
path: /health
port: 80
7 changes: 7 additions & 0 deletions cd/overlays/dev/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ resources:
- certificate.yaml

patches:
- target:
kind: Deployment
name: developer-portal
patch: |-
- op: replace
path: "/spec/template/spec/containers/0/image"
value: asia-docker.pkg.dev/prj-d-dev-apps-n3p4o97j/zilliqa/developer-portal:latest
- target:
kind: Ingress
name: developer-portal
Expand Down
3 changes: 3 additions & 0 deletions default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ server {

try_files $uri $uri/index.html =404;
}
location /health {
return 200 'healthcheck';
}

error_page 404 /zilliqa1/404.html;

Expand Down
28 changes: 28 additions & 0 deletions default.nozq2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
server {
listen 80;
server_name localhost;


port_in_redirect off;
server_name_in_redirect off;
absolute_redirect off;
rewrite ^/docs/(.*)$ /$1 permanent;
rewrite ^/$ /zilliqa1/ permanent;
rewrite ^/zilliqa1$ /zilliqa1/ permanent;

location / {
root /usr/share/nginx/html;
index index.html;

try_files $uri $uri/index.html =404;
}
location /health {
return 200 'healthcheck';
}

error_page 404 /zilliqa1/404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /zilliqa1/50x.html;
}
Loading

0 comments on commit 7ee2cb0

Please sign in to comment.