Skip to content

Commit e53f1e5

Browse files
hf-krechanKonstantin
andauthored
feat(sqlite): Use new SQLite Database (#553)
* update function to get ahb table from database * update function to get all format versions * WIP to update get all known prüfis * fix query for pruefis * remove D_ from Dataelements * update ahb line entity * add conditions in table view * remove duplicate SG * update ahb.db * put mapping into two functions * add line_type in orm model * remove unused import * fix segment name * wip column mapping * add line_type to openapi sepc * remove unused import * generate code from openapi spec * add line_type * use line type to define border style * getting closer * even closer * remove unused code sections * use isSegmentGroup * Change from data_element to data_element: thin line * refactor broder style matching * use git lfs * change filter for lfs to *.db * add fernet dependency * use encrypted database * add encrypted sqlite * ignore ahb.db * use lfs true for checkouts in github actions * ignore 7z files * add fenret key to dev and prod stacks * read and set fenret key * remove unused import * fix linter warnings by running `ng lint --fix` * set fernet key env var * use 7z * working approach 7z approach * remove duplicate code * remove fernet encrypted ahb db * use new env var name to clarify * remove fernet dependencies * update environment variable in pulumi * update secret for 7z archive * add environment variable for 7z archive password * update environment variable in test ci * add link to secret * update file name for encrypted database * use 7zip-min * feat(7z-decrypt): Use 7z in Dockerfile (#554) * use 7z in dockerfile * always replace 7z archive result * remove 7zip-min dependency * remove gitattributes for LFS * remove lfs * allow 7z files again * add 7z sqlite database * use most recent sqlite db (contains even more segment, doesn't have the 'SGSG' issue) https://github.com/Hochfrequenz/xml-migs-and-ahbs/releases/tag/v2025.04.12.8z * chore: Upgrade to Node 23.11 (#555) * upgrade to v23.11 * remove empty line * fix [ERROR] TS-992008: Could not find stylesheet file './fallback-page.component.css'. [0] [0] ✘ [ERROR] TS-992008: Could not find stylesheet file './fallback-page.component.css'. [plugin angular-compiler] [0] [0] src/app/shared/components/fallback-page/fallback-page.component.ts:7:14: [0] 7 │ styleUrls: ['./fallback-page.component.css'], [0] ╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [0] * remove fallback-page.component.css * clean dockerignore * improve dockerfile * add section to tell contributors that they need a password * update docker-compose * update example env * add docker environment * add docker env in bruno * update companystylesheet * add hint where the sqlite comes from * remove deprecated code lines * remove 7z relict --------- Co-authored-by: Konstantin <[email protected]>
1 parent 5a1b05b commit e53f1e5

Some content is hidden

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

42 files changed

+1526
-1133
lines changed

.dockerignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ node_modules
55
/.vscode
66
/.nx
77
/.angular
8-
.drone.yml
98
.editorconfig
109
.eslintrc.json
1110
.git
@@ -25,4 +24,3 @@ README.md
2524
.idea
2625
.octopus
2726
azure-mock
28-
node_modules

.example.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ AZURE_BLOB_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol='http;AccountName=
55
FORMAT_VERSION_CONTAINER_NAME=format-versions
66

77
OH_DEAR_HEALTH_CHECK_SECRET=my-secret-oh-dear-health-check-secret
8+
9+
DB_7Z_ARCHIVE_PASSWORD=my-secret-db-7z-archive-password

.github/workflows/action_pull_request.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ jobs:
1515
with:
1616
ref: ${{ github.event.pull_request.head.ref }}
1717
fetch-depth: 0
18-
1918
- uses: actions/setup-node@v4
2019
with:
2120
node-version: '20.13'
@@ -35,6 +34,10 @@ jobs:
3534

3635
- name: Unit tests
3736
run: npm test
37+
env:
38+
# secret is set in organization settings
39+
# https://github.com/organizations/Hochfrequenz/settings/secrets/actions/SQLITE_AHB_DB_7Z_ARCHIVE_PASSWORD
40+
DB_7Z_ARCHIVE_PASSWORD: ${{ secrets.SQLITE_AHB_DB_7Z_ARCHIVE_PASSWORD }}
3841

3942
- name: Build frontend
4043
run: npm run ng:build

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ Thumbs.db
4545
.nx/cache
4646
.nx/workspace-data
4747

48+
49+
src/server/data/ahb.db

.nvmrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
v20.13
2-
1+
v23.11

Dockerfile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,30 @@ WORKDIR /service
1717
RUN addgroup --system --gid 1001 nodejs && \
1818
adduser --system --uid 1001 nodejs
1919

20-
# Copy all necessary files into the image
20+
# Copy package files first for better caching
21+
COPY package*.json ./
22+
COPY tailwind.config.js ./
23+
24+
# Install dependencies
25+
RUN npm ci --no-scripts
26+
27+
# Copy the rest of the application
2128
COPY . .
2229

30+
# Install p7zip for 7z archive handling
31+
RUN apk add --no-cache p7zip
32+
33+
# Make scripts executable
34+
RUN chmod +x ./start.sh ./decrypt-db.sh
35+
2336
# Change ownership of the service folder and all copied files to the nodejs user
2437
RUN chown -R nodejs:nodejs /service
2538

26-
# Install dependencies
27-
RUN npm ci --no-scripts
28-
2939
# Switch to non-root user
3040
USER nodejs
3141

3242
# Expose port for the server
3343
EXPOSE 3000
3444

3545
# Start the application via start.sh script
36-
CMD ["sh", "./start.sh"]
46+
CMD ["sh", "./start.sh"]

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ $ npm install -g @angular/cli
7474

7575
Create an `.env` file in the root directory and paste the contents of the `.example.env` file.
7676

77+
> [!IMPORTANT]
78+
> The application requires a SQLite database to function.
79+
> This database is stored in an encrypted 7z archive at `src/server/data/ahb.db.encrypted.7z`.
80+
> You will need the password to decrypt this archive, which can be found in the Hochfrequenz 1Password vault at [this link](https://start.1password.com/open/i?a=F35NURJ4PFGOPBA77PR66C5P4I&v=vjgfwz7dg5wg656rfpvadetrqy&i=grnjb4hn6ipcau4bqe43rkuwnq&h=hochfrequenz.1password.com).
81+
>
82+
> If you don't have access to the 1Password vault, please ask your teamates how to get the password.
83+
>
84+
> To work locally, you need to decrypt the archive and store the decrypted file in at `src/server/data/ahb.db`.
85+
>
86+
> If you want to start the application with Docker, you need to set the `DB_7Z_ARCHIVE_PASSWORD` environment variable in the `docker-compose.yaml` file either by setting it directly or by using the `.env` file.
87+
> We recommend the latter to keep the `docker-compose.yaml` file clean and readable.
88+
7789
While having [Docker Desktop](https://www.docker.com/products/docker-desktop/) up and running, start the docker container using
7890

7991
```bash

angular.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@
4646
}
4747
]
4848
},
49+
"docker": {
50+
"outputHashing": "all",
51+
"fileReplacements": [
52+
{
53+
"replace": "src/app/environments/environment.ts",
54+
"with": "src/app/environments/environment.docker.ts"
55+
}
56+
]
57+
},
4958
"development": {
5059
"optimization": false,
5160
"extractLicenses": false,

bruno/Get AHB.bru

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
meta {
2+
name: Get AHB
3+
type: http
4+
seq: 5
5+
}
6+
7+
get {
8+
url: {{host}}/api/format-versions/FV2504/pruefis
9+
body: none
10+
auth: none
11+
}

bruno/environments/docker.bru

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vars {
2+
host: http://localhost:4000
3+
}

0 commit comments

Comments
 (0)