Skip to content

Commit 9ccd56a

Browse files
committed
more work on powersync and refactoring
1 parent d83f4ec commit 9ccd56a

10 files changed

Lines changed: 244 additions & 269 deletions

File tree

RELEASENOTES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
https://github.com/wger-project/docker/commit/ec5893553d81445485e5d32f5a6be637a12fd492
22

3+
## 1.0.0
4+
5+
* JWT Signing Key Setting has been removed
6+
* nginx and persistent storage is now mandatory
7+
* nginx get's it's own deployment
8+
* clean up unused volume definitions
9+
* new powersync service for offline sync with the app introduced
10+
* service and target ports changes
11+
312
## 0.3.0
413

514
* upgrade to wger 2.5

charts/wger/README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ For a more productive environment you have to enable nginx as a reverse proxy. T
1616

1717
* Kubernetes 1.15+
1818
* Helm 3.0+
19-
* PV infrastructure on the cluster if persistence is needed (recommended)
19+
* PV infrastructure on the cluster persistence is needed
2020
* Ingress infrastructure for exposing the installation
2121

2222

@@ -141,9 +141,8 @@ Celery requires persistent volumes.
141141

142142
| Name | Description | Type | Default Value |
143143
|-----------------------------|-------------|------|---------------|
144-
| `app.nginx.enabled` | Enable nginx as a proxy. This will enable persistent volumes, gunicorn and disable `DJANGO_DEBUG` | Boolean | `false` |
145-
| `app.nginx.image` | Image to use for the nginx proxy | String | `nginx:stable` |
146-
| `app.nginx.imagePullPolicy` | [Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) to use for the image | String | `IfNotPresent` |
144+
| `nginx.image` | Image to use for the nginx proxy | String | `nginx:stable` |
145+
| `nginx.imagePullPolicy` | [Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) to use for the image | String | `IfNotPresent` |
147146

148147

149148
## Ingress
@@ -170,15 +169,13 @@ Celery requires persistent volumes.
170169

171170
| Name | Description | Type | Default Value |
172171
|-----------------------------------------|--------------------------------------------------------------------|------|---------------|
173-
| `app.persistence.enabled` | Whether to enable persistent storage. If `false`, the options from below are ignored | Boolean | `false` |
172+
| `app.persistence.existingClaim.enabled` | Whether to use a existing persistent storage claim. If `false`, the options from below are ignored | Boolean | `false` |
174173
| `app.persistence.existingClaim.media` | Name of the pvc for the media data when existingClaim is enabled | String | `null` |
175174
| `app.persistence.existingClaim.static` | Name of the pvc for the static data when existingClaim is enabled | String | `null` |
176-
| `app.persistence.existingClaim.enabled` | Whether to use a existing persistent storage claim. If `false`, the options from below are ignored | Boolean | `false` |
177175
| `app.persistence.storageClass` | StorageClass for the PVCs | String | `""` |
178176
| `app.persistence.accessModes` | Access modes for the PVCs | Array | `["ReadWriteMany"]` |
179177
| `app.persistence.size` | PVC size | String | `8Gi` |
180178
| `app.persistence.annotations` | Annotations to attach to the persistence objects (PVC and PV) | Dictionary | `{}` |
181-
| `app.persistence.enabled` | Whether to enable persistent storage. If `false`, the options from below are ignored | Boolean | `false` |
182179

183180

184181
## Application Resources

charts/wger/templates/_helpers.tpl

Lines changed: 83 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ environment:
3434
value: "True"
3535
- name: DJANGO_DB_ENGINE
3636
value: {{ .Values.app.django.existingDatabase.engine | default "django.db.backends.postgresql" | quote }}
37-
- name: DJANGO_DB_HOST
38-
value: {{ .Values.app.django.existingDatabase.host | default (print .Release.Name "-postgres") | quote }}
39-
- name: DJANGO_DB_PORT
40-
value: {{ .Values.app.django.existingDatabase.port | default .Values.postgres.service.port | int | quote }}
4137
# cache
4238
- name: DJANGO_CACHE_BACKEND
4339
value: "django_redis.cache.RedisCache"
@@ -64,11 +60,7 @@ environment:
6460
value: "http://127.0.0.1,https://127.0.0.1,http://localhost,https://localhost"
6561
{{- end }}
6662
- name: DJANGO_DEBUG
67-
{{- if .Values.app.nginx.enabled }}
6863
value: "False"
69-
{{- else }}
70-
value: "True"
71-
{{- end }}
7264
- name: DJANGO_MEDIA_ROOT
7365
value: "/home/wger/media"
7466
# axes
@@ -96,16 +88,14 @@ environment:
9688
value: {{ int .Values.app.jwt.accessTokenLifetime | default "10" | quote }}
9789
- name: REFRESH_TOKEN_LIFETIME
9890
value: {{ int .Values.app.jwt.refreshTokenLifetime | default "24" | quote }}
99-
# others
100-
{{- if .Values.app.nginx.enabled }}
91+
# gunicorn settings
10192
- name: WGER_USE_GUNICORN
10293
value: "True"
10394
# workers (2x CPU Cores +1), rpi4 works well with 2 worker / 2 threads / 1 pod
10495
# forward-allow-ips="*" for image serving https url
10596
# accesslog: remote ip - client ip - x-real-ip - x-forward-for -
10697
- name: GUNICORN_CMD_ARGS
10798
value: "--timeout 240 --workers 4 --worker-class gthread --threads 3 --forwarded-allow-ips * --proxy-protocol True --access-logformat='%(h)s %(l)s %({client-ip}i)s %(l)s %({x-real-ip}i)s %(l)s %({x-forwarded-for}i)s %(l)s %(t)s \"%(r)s\" %(s)s %(b)s \"%(f)s\" \"%(a)s\"' --access-logfile - --error-logfile -"
108-
{{- end }}
10999
# Users won't be able to contribute to exercises if their account age is
110100
# lower than this amount in days.
111101
- name: MIN_ACCOUNT_AGE_TO_TRUST
@@ -169,11 +159,16 @@ environment:
169159
value: {{ .value | quote }}
170160
{{- end }}
171161
{{- end }}
162+
172163
{{/*
173164
database settings
174165
used for wger-app and celery containers
175166
*/}}
176167
{{- define "database.settings" }}
168+
- name: DJANGO_DB_HOST
169+
value: {{ .Values.app.django.existingDatabase.host | default (print .Release.Name "-postgres") | quote }}
170+
- name: DJANGO_DB_PORT
171+
value: {{ .Values.app.django.existingDatabase.port | default .Values.postgres.service.port | int | quote }}
177172
{{- if .Values.app.django.existingDatabase.enabled }}
178173
- name: DJANGO_DB_USER
179174
valueFrom:
@@ -212,7 +207,83 @@ environment:
212207
name: {{.Release.Name}}-postgres
213208
key: "POSTGRES_DB"
214209
{{- end }}
210+
# powersync database
211+
- name: PS_DATABASE_URI
212+
value: "postgres://${DJANGO_DB_USER}:${DJANGO_DB_PASSWORD}@${DJANGO_DB_HOST}:${DJANGO_DB_PORT}/${DJANGO_DB_DATABASE}"
215213
{{- end }}
214+
215+
{{/*
216+
powersync settings
217+
*/}}
218+
{{- define "powersync.settings" }}
219+
- name: JWT_PRIVATE_KEY
220+
valueFrom:
221+
secretKeyRef:
222+
name: {{ .Values.app.jwt.secret.name | default "jwt" | quote }}
223+
key: "private-key"
224+
- name: JWT_PUBLIC_KEY
225+
valueFrom:
226+
secretKeyRef:
227+
name: {{ .Values.app.jwt.secret.name | default "jwt" | quote }}
228+
key: "public-key"
229+
# This is the path (inside the container) to the YAML config file
230+
# Alternatively the config path can be specified in the command
231+
# e.g:
232+
# command: ['start', '-r', 'unified', '-c', '/config/powersync.yaml']
233+
#
234+
# The config file can also be specified in Base 64 encoding
235+
# e.g.: Via an environment variable
236+
# POWERSYNC_CONFIG_B64: [base64 encoded content]
237+
# or e.g.: Via a command line parameter
238+
# command: ['start', '-r', 'unified', '-c64', '[base64 encoded content]']
239+
- name: POWERSYNC_CONFIG_PATH
240+
{{- if .Values.powersync.configPath }}
241+
value: {{ .Values.powersync.configPath | quote }}
242+
{{- else }}
243+
value: "/config/powersync.yaml"
244+
{{- end }}
245+
# Sync rules can be specified as base 64 encoded YAML
246+
# e.g: Via an environment variable
247+
# POWERSYNC_SYNC_RULES_B64: "[base64 encoded sync rules]"
248+
# or e.g.: Via a command line parameter
249+
# command: ['start', '-r', 'unified', '-sync64', '[base64 encoded content]']
250+
- name: PS_JWKS_URL
251+
{{- if .Values.powersync.jwksURL }}
252+
value: {{ .Values.powersync.jwksURL | quote }}
253+
{{- else }}
254+
value: "http://{{ .Release.Name }}-http:80/api/v2/powersync-keys"
255+
{{- end }}
256+
- name: PS_PORT
257+
value: "8080"
258+
- name: POWERSYNC_URL_PATH
259+
value: "ps"
260+
# database settings
261+
- name: DJANGO_DB_HOST
262+
value: {{ .Values.app.django.existingDatabase.host | default (print .Release.Name "-postgres") | quote }}
263+
- name: DJANGO_DB_PORT
264+
value: {{ .Values.app.django.existingDatabase.port | default .Values.postgres.service.port | int | quote }}
265+
{{- if .Values.app.django.existingDatabase.enabled }}
266+
{{- if .Values.app.django.existingDatabase.existingSecret.dbnameKey }}
267+
- name: DJANGO_DB_DATABASE
268+
valueFrom:
269+
secretKeyRef:
270+
name: {{ .Values.app.django.existingDatabase.existingSecret.name | default (print .Release.Name "-existing-database") | quote }}
271+
key: {{ .Values.app.django.existingDatabase.existingSecret.dbnameKey | default "USERDB_NAME" | quote }}
272+
{{- else }}
273+
- name: DJANGO_DB_DATABASE
274+
value: {{ .Values.app.django.existingDatabase.dbname | default "wger" | quote }}
275+
{{- end }}
276+
{{- else }}
277+
- name: DJANGO_DB_DATABASE
278+
valueFrom:
279+
secretKeyRef:
280+
name: {{.Release.Name}}-postgres
281+
key: "POSTGRES_DB"
282+
{{- end }}
283+
- name: PS_STORAGE_PG_URI
284+
value: "postgres://powersync_storage:powersync_password@${DJANGO_DB_HOST}:${DJANGO_DB_PORT}/${DJANGO_DB_DATABASE}"
285+
{{- end }}
286+
216287
{{/*
217288
initContainer postgres command
218289
used for wger-app
@@ -225,6 +296,7 @@ environment:
225296
- until nc -zvw10 {{ $dbhost }} {{ $dbport }}; do echo "Waiting for postgres service ({{ $dbhost }}:{{ $dbport }}) "; sleep 2; done &&
226297
until nc -zvw10 {{.Release.Name}}-redis {{ .Values.redis.service.serverPort }}; do echo "Waiting for redis service ({{.Release.Name}}-redis:{{ .Values.redis.service.serverPort }})"; sleep 2; done
227298
{{- end }}
299+
228300
{{/*
229301
initContainer web command
230302
used for celery containers

charts/wger/templates/configmap.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{{- if .Values.app.nginx.enabled }}
21
kind: ConfigMap
32
apiVersion: v1
43
metadata:
@@ -8,13 +7,13 @@ data:
87
upstream app_server {
98
# fail_timeout=0 means we always retry an upstream even if it failed
109
# to return a good HTTP response <- according to gunicorn doc
11-
server 127.0.0.1:8000 fail_timeout=0;
10+
server {{.Release.Name}}-app.{{.Release.Namespace}}.svc.cluster.local:8000 fail_timeout=0;
1211
zone upstreams 64K;
1312
keepalive 2;
1413
}
1514
# Used by the /ps/ proxy below.
1615
upstream powersync {
17-
server powersync:8080;
16+
server {{.Release.Name}}-powersync-api.{{.Release.Namespace}}.svc.cluster.local:8080;
1817
}
1918
2019
# custom access log configuration
@@ -115,7 +114,6 @@ data:
115114
# Increase max body size to allow for video uploads
116115
client_max_body_size 100M;
117116
}
118-
{{- end }}
119117
120118
---
121119
kind: ConfigMap

0 commit comments

Comments
 (0)