This document contains notes and tips on the development of the app.
To locally run a prebuilt Docker image, which has been pushed to an image repository like GitHub Packages or DockerHub:
- Start Docker Desktop and log in with your credentials.
- In PowerShell,
cd
into the app repository folder. - Run
docker run -it -p 4201:4201 --rm ghcr.io/slsfi/digital-edition-frontend-ng:main
where you should replace ghcr.io/slsfi/digital-edition-frontend-ng:main
with the URL to the remote image you want to run.
- Open your browser on http://localhost:4201/.
To first build and then run a Docker image of a local copy of the repository on your own machine:
- Start Docker Desktop and log in with your credentials.
- In PowerShell,
cd
into the app repository folder. - Run
docker build --no-cache -t digital-edition-frontend-ng:test .
(notice the dot at the end) to build the image from the current directory, where digital-edition-frontend-ng:test
is the name and tag of the image. You can choose a different name and tag if you wish.
- Run
docker run -it -p 4201:4201 --rm digital-edition-frontend-ng:test
to run the image. If you built the image with a different name and tag in step 3, replace digital-edition-frontend-ng:test
with your chosen name:tag
.
- Open your browser on http://localhost:4201/.
In production, nginx is run in a Docker container in front of the app container so nginx, which is more performant than Node.js, can server static files. To run the app in this setup locally:
- Start Docker Desktop and log in with your credentials.
- In PowerShell,
cd
into the app repository folder. - Run
docker build --no-cache -t digital-edition-frontend-ng:test .
(notice the dot at the end) to build the image from the current directory, where digital-edition-frontend-ng:test
is the name and tag of the image. You can choose a different name and tag if you wish.
- Replace the URL of
image
in theweb
service incompose.yml
withdigital-edition-frontend-ng:test
(or thename:tag
you built the image with in step 3). Do not commit this change! - Run
docker compose up -d
- Open your browser on http://localhost:2089/ (the port of the nginx service defined in
compose.yml
). - Undo the changes in
compose.yml
. - When you are done testing, stop the Docker containers in Docker Desktop and delete all containers and volumes that were created. Alternatively you can do this in the terminal by running
docker compose down --volumes
The Node.js Docker-image tag can be passed as a build argument to Dockerfile
using the argument NODE_IMAGE_TAG
. Dockerfile
sets a default value for the argument if it is not passed.
By default the app is built using GitHub Actions according to the workflow defined in .github/workflows/docker-build-and-push.yml
, but you can also define your own build workflow. The Node.js image which is used as the base image for the build is defined in the workflow YAML-file and passed to Dockerfile
.
When updating which Node.js image is used for the build, remember to update both docker-build-and-push.yml
and Dockerfile
.
The app is built on Angular and uses many web components from Ionic. It also has a few other essential dependencies, which are briefly described below.
The Angular documentation is available on https://angular.dev/.
At it’s root, the Angular app uses NgModules, even though all components except pages
use the standalone API. This is because currently, another dependency, Ionic
, doesn’t support the Angular standalone API for SSR apps.
Run
ng update @angular/cli @angular/core
For more detailed instructions see https://angular.dev/cli/update.
When updating to a new major version of Angular:
- See the interactive Angular update guide.
- Update the line in
Dockerfile
which indicates the Angular major version number:ARG ANGULAR_MAJOR_VERSION=<major_version>
.
The Ionic Framework documentation is available on https://ionicframework.com/docs/
Run
npm install @ionic/angular @ionic/angular-server
Library for rendering ePub documents in the browser, used by the epub-viewer
component in the app. It is poorly documented and not actively maintained anymore. It works without problems only in Firefox.
Framework for running a web server in Node.js. This library is required by Angular to enable server-side rendering.
SSR-compatible HTML/XML parser, used in a few places in the app to parse HTML from the backend.
Iconset especially intended to be used with Ionic.
SSR-compatible markdown parser. Parses markdown to HTML. Any HTML in the markdown is passed through as it is.
Reactive extensions library. Used internally by Angular and heavily in the app for handling Observables.
Runtime library for TypeScript containing all of the TypeScript helper functions. Required by Angular.
Library for execution contexts (”zones”) that persist across async tasks. Required by Angular.
browser-sync
(devDependency)
Required by the Angular builders.
copyfiles
(devDependency)
Library for copying files. Used by the build:ssr
script in package.json
to copy the proxy-server.js
file into the dist/app
folder once the Angular app has been built.
gzipper
(devDependency)
Library for compressing files. Used in Dockerfile
in a post-build step to create compressed (gzip) versions of static files. It’s configured in the compress
script in package.json
.
ng-extract-i18n-merge
(devDependency)
Library for extracting and merging i18n xliff translation files for Angular projects. This library extends the default Angular CLI, and is used to sort the keys in the xliff translation files. Used when running the extract-i18n
script in package.json
to create the xliff translation files for the app.
Testing frameworks.