Step 7: Media
The media service is used for managing the uploaded records of My Media Lib.
Create folder
Create the folder where the configuration and uploaded records will be.
mkdir media media/records
Configuration
Copy the default.appsettings.json to ~/medialib/media/appsettings.json on server. Remove the default. part of the filename.
Replace the app keys.
cat ~/medialib/identity/appsettings.json
...
"ADMIN_APP_KEY": "<admin_app_key>",
"APP_KEY": "<app_key>",
...
Replace the name of the pfx certificate and set your pfx password.
"TLS": {
"Cert": "/certs/<name of cert>.pfx",
"Password": "<password>"
},
Remove the TLS section or leave Cert empty to run the service on http, if TLS is terminated by the reverse proxy or an external proxy. The service trusts the forwarded headers of the reverse proxy from private networks. To restrict them, set the networks of the reverse proxy in ForwardedHeaders:KnownNetworks, e.g. the subnet of the docker network wekode.mml.
"ForwardedHeaders": {
"KnownNetworks": [ "172.18.0.0/16" ]
},
Replace the connection string with values you defined when creating the database for the service.
"ConnectionStrings": {
"MediaConnection": "Server=wekode.mml.db;Port=5432;Database=media;User Id=media;Password=media;"
},
Set issuer url to your domain and port you are using as ssl port.
"OpenId": {
"Issuer": "https://<url>:<port>/"
},
Set the api client id and secret you defined when setting up the identity service.
"ApiClient": {
"ClientId": "<ClientId>",
"ClientSecret": "<ClientSecret>"
},
Replace the rabbitmq user and password with the values you defined when setting up the message bus service.
"MessageBus": {
"Host": "wekode.mml.mbus",
"User": "guest",
"Password": "guest",
"VirtualHost": "/",
"WaitUntilStarted": true,
"StartTimeoutSeconds": 10,
"StopTimeoutSeconds": 30,
"ConcurrentMessageLimit": 10
}
Records
"Records": {
"MaxCoverSizeMb": 8
},
| Setting | Description |
|---|---|
MaxCoverSizeMb | Largest cover an admin can set in the record details, 8 MB by default. Larger images are rejected. Covers from the id3 tags of uploaded records and from partners are not limited. The cover is sent base64 encoded, so the request is about a third larger than the image and must stay below the FILE_UPLOAD_LIMIT of the reverse proxy. |
Storage
"Storage": {
"Paths": {
"Records": "/records",
"Data": "/"
}
},
| Setting | Description |
|---|---|
Paths | Paths inside the Media container whose filesystem usage the admin app shows in the settings, by name. Records is the volume VOL_RECORDS, Data is the filesystem Docker stores the containers on, which usually also holds the database. These two are used if the section is missing. Paths that do not exist are left out. See Storage usage. |
Share
"Share": {
"MaxRecordsPerLink": 200,
"StylingPath": "/configs/styling.json"
},
| Setting | Description |
|---|---|
MaxRecordsPerLink | Largest number of records in one download link, 200 by default, at most 10000. The apps show the limit when a selection is too large. |
StylingPath | Path of the styling of the share pages inside the container. Keep the default and mount another file with MEDIA_STYLING instead. |
Federation
Federation synchronizes records with other My Media Lib instances. It is always enabled. Partners reach this instance at the issuer address configured in OpenId:Issuer. Set PublicUrl only if partners use another public HTTPS address, with the ssl port if it is not 443.
"Federation": {
"PublicUrl": "",
"AllowPrivateNetworks": false,
"KeysPath": "/secrets/federation",
"KeyRotationDays": 90,
"KeyPublishLeadDays": 7,
"KeyRetireDays": 14,
"ChunkSizeMb": 32,
"MaxRecordSizeMb": 2048,
"UploadPath": "/tmp/records/federation",
"UploadRetentionDays": 7,
"MaxOpenTransfers": 10
},
| Setting | Description |
|---|---|
PublicUrl | Public HTTPS address partners reach this instance at. Empty uses OpenId:Issuer. When the address changes, linked partners are informed after the next start, see address changes. |
AllowPrivateNetworks | Allows partners with addresses in private networks, e.g. in a local network. Disabled by default. |
KeysPath | Folder of the signing keys. Must be inside the secrets volume MEDIA_SECRETS_PATH configured below. |
KeyRotationDays, KeyPublishLeadDays, KeyRetireDays | Rotation of the signing keys: a new key every 90 days, published 7 days before use, the old key is removed 14 days later. |
ChunkSizeMb | Size of the parts records are sent in. Must be smaller than the FILE_UPLOAD_LIMIT of every partner. |
MaxRecordSizeMb | Largest record accepted from partners. |
UploadPath, UploadRetentionDays | Folder of unfinished transfers from partners and the days they are kept without progress. |
MaxOpenTransfers | Unfinished transfers one partner may have at the same time. Further transfers are rejected until one is finished or removed. |
Partners are identified by the INSTANCE name in the .env file. Every instance needs a unique name consisting of letters, digits, ., _ or - with up to 64 characters. Do not change the name after the first start, the Media service refuses to start with another name, see Instance name.
Style the share pages
The public pages of share links show the title of your mobile app and use the colors of the WeKoDe design system, which the app uses by default, so they look like the app. The texts of the pages are shown in English, German, Russian or Ukrainian depending on the language of the browser. Title and colors are configured in the file styling.json, which is filled with the title of the unchanged app and the WeKoDe colors. You only need it, if you customized the title of the app or want other colors.
Copy styling.json to ~/medialib/media/styling.json on the server and adjust the values. The file is read when the service starts.
{
"title": {
"default": "Meine Mediathek",
"de": "Meine Mediathek",
"en": "My Media Lib",
"ru": "Моя Медиятека",
"uk": "Моя медіатека"
},
"colors": {
"light": {
"surface": "#F8F9FC",
"onSurface": "#191C20",
"surfaceContainerHighest": "#E1E2E8",
"onSurfaceVariant": "#43474E",
"primary": "#0E42A0",
"onPrimary": "#FFFFFF",
"primaryContainer": "#D8E2FF",
"onPrimaryContainer": "#001A41",
"outline": "#686C74"
},
"dark": {
"surface": "#111318",
"onSurface": "#E1E2E8",
"surfaceContainerHighest": "#33353A",
"onSurfaceVariant": "#C3C6CF",
"primary": "#B3C6E8",
"onPrimary": "#002E69",
"primaryContainer": "#004494",
"onPrimaryContainer": "#D8E2FF",
"outline": "#8D9199"
}
}
}
| Setting | Description |
|---|---|
title | Title of the app per language, as set in the app.cfg of your app. default is used for all languages which are not listed. |
colors | Colors of the light and dark theme as hex values like #0E42A0. The names are the names of the color roles of the Material color scheme. Invalid or missing values use the default WeKoDe colors. outline is no longer used by the pages and can be left out. |
Set MEDIA_STYLING in the .env file to the path of the file and restart the service, see below. Without the setting or with a missing or invalid file the defaults are used.
Update .env file and start service
Update the required values in the ~/medialib/.env file.
Actual docker image can be found on docker-hub.
cat .env
## media configuration section
## The docker tag to be used.
MEDIA_VERSION=1.2.1
## Path and name on host machine where the appsettings is stored.
## for example /app/config/appsettings.json
MEDIA_APPSETTINGS=/home/mml/medialib/media/appsettings.json
## Path to the folder on host where to backup the uploaded and indexed records.
VOL_RECORDS=/home/mml/medialib/media/records
## The path where the federation keys of the media service are stored.
MEDIA_SECRETS_PATH=/home/mml/medialib/media/secrets
## Optional. Path and name on host machine where the styling of the share pages is stored.
#MEDIA_STYLING=/home/mml/medialib/media/styling.json
## Optional. Path to the file on host with the secret to encrypt the federation keys stored in MEDIA_SECRETS_PATH.
#FEDERATION_KEY_SECRET_FILE=/home/mml/medialib/media/federation.secret
The signing keys of the federation are created automatically in MEDIA_SECRETS_PATH. Keep this folder when updating the service, otherwise partners have to load new keys. The folder must be writable by the docker user; the service cannot create keys otherwise and federation requests fail.
The secret in the file FEDERATION_KEY_SECRET_FILE encrypts the stored keys. Create it like the secrets of the identity service, e.g. openssl rand -base64 32 > media/federation.secret. FEDERATION_KEY_SECRET with the secret itself is still supported, if no file is configured. Keys stored without encryption are encrypted automatically when the secret is set later. If the secret is changed or removed, existing encrypted keys cannot be read anymore and the service reports an error. In this case delete the files in MEDIA_SECRETS_PATH: new keys are created and partners load them automatically.
Set user rights of the folders to the docker user and start the service.
mkdir -p media/secrets
sudo chown -R 1001:1001 media/
sudo chown -R 1001:1001 media/records
sudo chown -R 1001:1001 media/secrets
sudo docker compose up wekode.mml.media -d
Check
sudo docker compose ps wekode.mml.media
sudo docker compose logs wekode.mml.media
The container is running and the log shows no errors, e.g. about the INSTANCE name, the database or the message bus.