Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2e6d459
Update dependencies to match production
joonas-somero Sep 12, 2024
e6faeed
Add build() back
lvarin Nov 8, 2024
bd964d0
NO need for that
lvarin Nov 8, 2024
6cb1b67
Revert "Update dependencies to match production (#44)"
lvarin Nov 8, 2024
99fcb12
Revert "Revert "Update dependencies to match production (#44)""
lvarin Nov 8, 2024
6842671
Revert "NO need for that"
lvarin Nov 8, 2024
96c8a3a
Revert "Revert "Use threads instead" (#45)"
lvarin Nov 8, 2024
b057d48
Merge pull request #46 from CSCfi/revert-all
trispera Nov 8, 2024
1e655f6
Read and write state to a file, so we do not rebuild the whole this e…
lvarin Nov 11, 2024
f3cae2e
Add try/except so it does not die when the state file is missing
lvarin Nov 12, 2024
de1e43e
First version, allows a deployment of the repository and basic custom…
lvarin Nov 8, 2024
c396cdb
Bump werkzeug from 2.3.8 to 3.0.3 (#38)
dependabot[bot] Nov 12, 2024
b784d19
Bump zipp from 3.8.1 to 3.19.1 (#40)
dependabot[bot] Nov 12, 2024
07b14aa
Improve logging
lvarin Nov 12, 2024
4c985e0
Add parallel build of only the PR branch, this must be merged the last
lvarin Nov 19, 2024
b610012
Rename function
lvarin Nov 19, 2024
0ada5d0
Small curly brances fix
lvarin Nov 19, 2024
46cf85d
Bump werkzeug from 2.3.8 to 3.0.3 (#38)
dependabot[bot] Nov 12, 2024
2acf241
Add some docs on the chart
lvarin Nov 25, 2024
2a1c578
Add some docs on the chart
lvarin Nov 25, 2024
0f5ca62
Merge pull request #47 from lvarin/helm
trispera Nov 26, 2024
67c213f
Merge pull request #48 from lvarin/save_state
trispera Nov 26, 2024
0eaa30b
Merge branch 'master' into logging
trispera Nov 26, 2024
ad78126
Merge pull request #49 from lvarin/logging
trispera Nov 26, 2024
63aedeb
Merge branch 'master' into parallel
trispera Nov 26, 2024
3d58d0b
Merge pull request #50 from lvarin/parallel
trispera Nov 26, 2024
9b07433
Fix spaces with 'reindent'
lvarin Nov 28, 2024
b15348c
Reorder imports and add docs to app.py
lvarin Nov 29, 2024
163bac5
Add encoding to file open operations
lvarin Nov 29, 2024
6816bd2
Rename function and variables to conform PEP8
lvarin Nov 29, 2024
ed422e0
Rename function and variables to conform to PEP8
lvarin Nov 29, 2024
f40b91a
Use f-strings instead of other methods
lvarin Nov 29, 2024
9cfa4fe
Add doc strings to functions
lvarin Nov 29, 2024
aabe2a0
Split line to make shorter and use sys.exit
lvarin Nov 29, 2024
01a4f32
Add content type to response, do not use ==, and use sys.exit
lvarin Nov 29, 2024
ad107c9
Rename variables so they follow PEP8 snake_case
lvarin Nov 29, 2024
f723787
Exit earlier, instead of nested checks
lvarin Nov 29, 2024
f559cbc
Merge pull request #52 from lvarin/pylint
trispera Dec 9, 2024
51ec910
Merge pull request #53 from lvarin/pylint2
trispera Dec 9, 2024
973db62
Merge branch 'master' into devel
lvarin Jan 7, 2025
b22385e
Try to solve zombies issue:
lvarin Jan 7, 2025
fe3153b
Upgrade Jinja2
lvarin Jan 7, 2025
1a63a42
Merge pull request #55 from CSCfi/devel
trispera Jan 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
463 changes: 322 additions & 141 deletions app.py

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: helm
description: Deploys docs-preview in Kubernetes
type: application
version: 0.2.0
appVersion: "1.2.0"
30 changes: 30 additions & 0 deletions helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Helm chart to deploy `docs-preview`

> Original repository is <https://github.com/cscfi/docs-preview>

This chart deploys docs-preview, which will clone a given repository (by default <https://github.com/cscfi/csc-user-guide>),
and build every single branch in the repository. The branches will be available via a web interface. It also offers a API that understands
GitHub hooks and rebuilds the given branch by the hook.

## Parameters

* `values.yaml`:
```yaml
git:
source: https://github.com/cscfi/docs-preview
docs: https://github.com/cscfi/csc-user-guide
secret:

host: csc-guide-preview.rahtiapp.fi

replicas: 1
```

|Key|Description|Default|
|:-:|:-:|:-:|
|git.source|The source (including `app.py`) to deploy|https://github.com/cscfi/docs-preview|
|git.docs|The repository hosting the documentation to build|https://github.com/cscfi/csc-user-guide|
|secret|Secret to be used in the web-hook|<empty>|
|host|URL to deploy the public web interface|`csc-guide-review.rahtiapp.fi`|
|replicas|Number of replicas for the Pod|1|

17 changes: 17 additions & 0 deletions helm/templates/csc-guide-preview-hook-route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: docs-preview-build-hook
spec:
host: {{ .Release.Namespace }}-hook.2.rahtiapp.fi
port:
targetPort: 8081
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
to:
kind: Service
name: docs-preview-hook
weight: 100
wildcardPolicy: None
status: {}
19 changes: 19 additions & 0 deletions helm/templates/csc-guide-preview-route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: route.openshift.io/v1
kind: Route
metadata:
labels:
app: docs-preview
name: docs-preview-route
spec:
host: {{ .Values.host }}
port:
targetPort: 8080-tcp
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
to:
kind: Service
name: docs-preview
weight: 100
wildcardPolicy: None
status: {}
30 changes: 30 additions & 0 deletions helm/templates/docs-preview-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
labels:
app: docs-preview
name: docs-preview
spec:
failedBuildsHistoryLimit: 2
output:
to:
kind: ImageStreamTag
name: docs-preview:latest
postCommit: {}
resources: {}
runPolicy: Serial
source:
git:
uri: {{ .Values.git.source }}
type: Git
strategy:
sourceStrategy:
from:
kind: DockerImage
name: registry.fedoraproject.org/f33/python3
type: Source
successfulBuildsHistoryLimit: 1
triggers:
- type: ImageChange
- type: ConfigChange
status: {}
87 changes: 87 additions & 0 deletions helm/templates/docs-preview-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
image.openshift.io/triggers: '[{"from":{"kind":"ImageStreamTag","name":"docs-preview:latest"},"fieldPath":"spec.template.spec.containers[?(@.name==\"docs-preview\")].image"}]'
labels:
app: docs-preview
name: docs-preview
spec:
progressDeadlineSeconds: 600
replicas: {{ .Values.replicas }}
revisionHistoryLimit: 10
selector:
matchLabels:
deployment: docs-preview
strategy:
type: Recreate
template:
metadata:
labels:
deployment: docs-preview
spec:
containers:
- image: bitnami/nginx:1.16-centos-7
imagePullPolicy: IfNotPresent
name: web-server
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: "1"
memory: 1G
requests:
cpu: 200m
memory: 200M
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /app
name: content-vol
- mountPath: /opt/bitnami/nginx/conf/server_blocks
name: nginx-conf
- env:
- name: BUILDSECRET
value: {{ .Values.secret }}
- name: BUILDROOT
value: /builds
- name: WORKPATH
value: /work
- name: REMOTEURL
value: {{ .Values.git.docs }}
image: ' ' # image-registry.openshift-image-registry.svc:5000/{{ .Release.Namespace }}/docs-preview:latest
imagePullPolicy: IfNotPresent
name: docs-preview
ports:
- containerPort: 8081
protocol: TCP
resources:
limits:
cpu: "1"
memory: 1G
requests:
cpu: 200m
memory: 200M
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /builds
name: content-vol
- mountPath: /work
name: workpath
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: content-vol
- emptyDir: {}
name: workpath
- configMap:
defaultMode: 420
name: nginx-config
name: nginx-conf
status: {}
19 changes: 19 additions & 0 deletions helm/templates/docs-preview-hook-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: docs-preview-hook
spec:
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- port: 8081
protocol: TCP
targetPort: 8081
selector:
deployment: docs-preview
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
5 changes: 5 additions & 0 deletions helm/templates/docs-preview-is.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: docs-preview
status: {}
22 changes: 22 additions & 0 deletions helm/templates/docs-preview-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: docs-preview
name: docs-preview
spec:
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
selector:
deployment: docs-preview
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
16 changes: 16 additions & 0 deletions helm/templates/nginx-conf-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
data:
my_server_block.conf: |
server {
listen 8080;
location / {
root /app;
index index.html;
autoindex on;
}
#rewrite ^/(.*[^/])$ $scheme://$http_host/$1/ permanent;
port_in_redirect off;
}
kind: ConfigMap
metadata:
name: nginx-config
8 changes: 8 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
git:
source: https://github.com/cscfi/docs-preview
docs: https://github.com/cscfi/csc-user-guide
secret:

host: csc-guide-preview.rahtiapp.fi

replicas: 1
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Additional packages for preview
Flask==2.2.5
itsdangerous==2.1.2
werkzeug==3.0.3
werkzeug==3.0.6

# Packages for building the static pages
babel==2.16.0
Expand All @@ -14,7 +14,7 @@ ghp-import==2.1.0
gitdb==4.0.11
GitPython==3.1.43
idna==3.7
Jinja2==3.1.4
Jinja2==3.1.5
Markdown==3.6
MarkupSafe==2.1.5
mergedeep==1.3.4
Expand Down Expand Up @@ -42,3 +42,4 @@ six==1.16.0
smmap==5.0.1
urllib3==2.2.2
watchdog==4.0.2

Loading