Skip to content

Commit

Permalink
Merge pull request #5313 from akvo/dbml-dbdocs
Browse files Browse the repository at this point in the history
Generate dbml file and push it to dbdocs.io
  • Loading branch information
zuhdil authored Oct 5, 2023
2 parents 7299116 + 73e7b64 commit 9fc8b64
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,4 @@ scripts/data/dumps/

public/
doc/modules/
rsr.dbml
1 change: 1 addition & 0 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ blocks:
- name: GCP
- name: docker-hub-credentials
- name: coveralls
- name: dbdocs-token
prologue:
commands:
- checkout
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile-dbdocs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Use an official Node.js image as the base image
FROM node:14

# Set the working directory in the container
WORKDIR /app

# Install dbdocs globally using npm
RUN npm install -g dbdocs
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ api: Makefile
--module-first \
--separate \
-o doc/modules \
-H "Reference documentation" \
--force \
akvo \
'*/migrations/*' \
Expand Down
1 change: 1 addition & 0 deletions akvo/settings/10-base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ INSTALLED_APPS = (
"django_otp.plugins.otp_totp",
'two_factor.plugins.phonenumber',
"two_factor",
'django_dbml',
)

gettext = lambda s: s
Expand Down
7 changes: 6 additions & 1 deletion ci/build-semaphoreci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ if [[ ! "${SKIP_BACKEND_TESTS:-}" = yes ]]; then
run web scripts/docker/dev/run-as-user.sh scripts/docker/ci/build.sh
fi

if [[ -n "${DBDOCS_TOKEN:-}" ]] && [[ -f rsr.dbml ]]; then
log Generate dbml file and push it to dbdocs.io
docker build --rm=false -t rsr-dbdocs -f Dockerfile-dbdocs .
docker run --rm -e DBDOCS_TOKEN="${DBDOCS_TOKEN}" -v $(pwd):/app rsr-dbdocs dbdocs build rsr.dbml --project=rsr
fi

#log Stopping docker-compose
#docker-compose -p rsrci -f docker-compose.yaml -f docker-compose.ci.yaml down

Expand All @@ -93,7 +99,6 @@ echo "DEPLOY_COMMIT_FULL_ID = $(quote "`git rev-parse HEAD`")" > ._66_deploy_inf
echo "DEPLOY_COMMIT_ID = $(quote "`git rev-parse --short HEAD`")" >> ._66_deploy_info.conf
echo "DEPLOY_BRANCH = $(quote "$CI_BRANCH")" >> ._66_deploy_info.conf


docker_build akvo/rsr-backend-prod-no-code -f Dockerfile-prod-no-code .

log Creating Production Backend image with code
Expand Down
3 changes: 1 addition & 2 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Table of Contents
:maxdepth: 2
components/index.md
modules/modules.rst
references.md
dev.md
deploying.md
```
Expand All @@ -30,5 +30,4 @@ Indices and tables
==================

* {ref}`genindex`
* {ref}`modindex`
* {ref}`search`
16 changes: 16 additions & 0 deletions doc/references.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Reference documentation
=======================

Database Schema
---------------

[https://dbdocs.io/akvo/rsr](https://dbdocs.io/akvo/rsr)

Module Index
------------

```{toctree}
:maxdepth: 2
modules/akvo
```
2 changes: 0 additions & 2 deletions docker-compose.ci.prod.images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,5 @@ services:
web:
image: rsr-backend:dev
command: "true"
rsrdbhost:
rsr-memcached:
volumes:
media-disk:
4 changes: 4 additions & 0 deletions scripts/deployment/pip/requirements/2_rsr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ django-bootstrap3==15.0.0 \
django-crontab==0.7.1 \
--hash=sha256:1201810a212460aaaa48eb6a766738740daf42c1a4f6aafecfb1525036929236
# via -r scripts/deployment/pip/requirements/production.in
django-dbml==0.6.0 \
--hash=sha256:2a3d4fb54e4c3992c5615d5c7b7f42cf34038c5652a456db05d3b807195c80f6 \
--hash=sha256:e61ad4cbfeba08b8f40573f96a9f40e3e35d1cb5c270370313aba02a8272eff5
# via -r scripts/deployment/pip/requirements/production.in
django-embed-video==1.4.0 \
--hash=sha256:243e489fdb618dde4e9112ce51db1e651724d6b287122ce29662beade0e53362 \
--hash=sha256:760af922e77fb1db5f6e9c5f1e35ecdca8dd35402d7a71f24c03f1ecb284be01
Expand Down
4 changes: 4 additions & 0 deletions scripts/deployment/pip/requirements/3_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ django-cprofile-middleware==1.0.5 \
django-crontab==0.7.1 \
--hash=sha256:1201810a212460aaaa48eb6a766738740daf42c1a4f6aafecfb1525036929236
# via -r scripts/deployment/pip/requirements/production.in
django-dbml==0.6.0 \
--hash=sha256:2a3d4fb54e4c3992c5615d5c7b7f42cf34038c5652a456db05d3b807195c80f6 \
--hash=sha256:e61ad4cbfeba08b8f40573f96a9f40e3e35d1cb5c270370313aba02a8272eff5
# via -r scripts/deployment/pip/requirements/production.in
django-debug-toolbar==3.8.1 \
--hash=sha256:24ef1a7d44d25e60d7951e378454c6509bf536dce7e7d9d36e7c387db499bc27 \
--hash=sha256:879f8a4672d41621c06a4d322dcffa630fc4df056cada6e417ed01db0e5e0478
Expand Down
2 changes: 2 additions & 0 deletions scripts/deployment/pip/requirements/production.in
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,5 @@ google-cloud-profiler

phonenumbers
django-two-factor-auth

django-dbml
4 changes: 4 additions & 0 deletions scripts/docker/ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ if [[ -n "${COVERALLS_REPO_TOKEN}" ]] ; then
coveralls
fi

if [[ "${CI_BRANCH}" == "master" ]]; then
./manage.py dbml rsr password_policy auth contenttypes > rsr.dbml
fi

log Done

0 comments on commit 9fc8b64

Please sign in to comment.