diff --git a/aspnetcore/openshift/indexer/rahti2/Dockerfile b/aspnetcore/openshift/indexer/rahti2/Dockerfile new file mode 100644 index 0000000..c09c100 --- /dev/null +++ b/aspnetcore/openshift/indexer/rahti2/Dockerfile @@ -0,0 +1,29 @@ +# Builder +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env +WORKDIR /build + +# Copy csproj and restore as distinct layers +COPY ["packages","./packages"] +COPY ["aspnetcore/nuget.config","./Indexer/nuget.config"] +COPY ["aspnetcore/src/Indexer/Indexer.csproj","./Indexer/Indexer.csproj"] +COPY ["aspnetcore/src/ElasticService/ElasticService.csproj","./ElasticService/ElasticService.csproj"] +COPY ["aspnetcore/src/DatabaseContext/DatabaseContext.csproj","./DatabaseContext/DatabaseContext.csproj"] +COPY ["aspnetcore/src/Repositories/Repositories.csproj","./Repositories/Repositories.csproj"] +COPY ["aspnetcore/src/Service.Models/Service.Models.csproj","./Service.Models/Service.Models.csproj"] +COPY ["aspnetcore/src/Logging/Logging.csproj","./Logging/Logging.csproj"] +RUN dotnet restore "Indexer/Indexer.csproj" + +# Copy everything else and build +COPY ["aspnetcore/src/Indexer/","./Indexer"] +COPY ["aspnetcore/src/ElasticService/","./ElasticService"] +COPY ["aspnetcore/src/DatabaseContext/","./DatabaseContext"] +COPY ["aspnetcore/src/Repositories/","./Repositories"] +COPY ["aspnetcore/src/Service.Models/","./Service.Models"] +COPY ["aspnetcore/src/Logging/","./Logging"] +RUN dotnet publish "Indexer/Indexer.csproj" -c Release -o out + +# Runtime image +FROM mcr.microsoft.com/dotnet/runtime:6.0 +WORKDIR /app +COPY --from=build-env /build/out . +ENTRYPOINT ["dotnet", "CSC.PublicApi.Indexer.dll"] \ No newline at end of file diff --git a/aspnetcore/openshift/indexer/rahti2/template-indexer-app-devel.yml b/aspnetcore/openshift/indexer/rahti2/template-indexer-app-devel.yml new file mode 100644 index 0000000..7121a19 --- /dev/null +++ b/aspnetcore/openshift/indexer/rahti2/template-indexer-app-devel.yml @@ -0,0 +1,52 @@ +# This file is part of the research.fi api +# +# Copyright 2024 Ministry of Education and Culture, Finland +# +# :author: CSC - IT Center for Science Ltd., Espoo Finland servicedesk@csc.fi +# :license: MIT +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + labels: + app: publicapi-indexer-devel + template: publicapi-indexer-devel + name: publicapi-indexer-devel + annotations: + description: "Public API indexer devel - Build and ImageStream" + iconClass: icon-dotnet +objects: + + # ImageStream + - apiVersion: image.openshift.io/v1 + kind: ImageStream + metadata: + name: publicapi-indexer-devel + labels: + app: publicapi-indexer-devel + spec: + lookupPolicy: + local: true + + # BuildConfig using Docker build strategy + - apiVersion: build.openshift.io/v1 + kind: BuildConfig + metadata: + name: publicapi-indexer-build-devel + labels: + app: publicapi-indexer-devel + spec: + source: + git: + uri: https://github.com/CSCfi/research-fi-publicapi.git + ref: devel + contextDir: . + strategy: + type: Docker + dockerStrategy: + dockerfilePath: aspnetcore/openshift/indexer/rahti2/Dockerfile + output: + to: + kind: ImageStreamTag + name: publicapi-indexer-devel:latest + successfulBuildsHistoryLimit: 2 + failedBuildsHistoryLimit: 2 diff --git a/aspnetcore/openshift/indexer/rahti2/template-indexer-app-production.yml b/aspnetcore/openshift/indexer/rahti2/template-indexer-app-production.yml new file mode 100644 index 0000000..db77298 --- /dev/null +++ b/aspnetcore/openshift/indexer/rahti2/template-indexer-app-production.yml @@ -0,0 +1,52 @@ +# This file is part of the research.fi api +# +# Copyright 2024 Ministry of Education and Culture, Finland +# +# :author: CSC - IT Center for Science Ltd., Espoo Finland servicedesk@csc.fi +# :license: MIT +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + labels: + app: publicapi-indexer-production + template: publicapi-indexer-production + name: publicapi-indexer-production + annotations: + description: "Public API indexer production - Build and ImageStream" + iconClass: icon-dotnet +objects: + + # ImageStream + - apiVersion: image.openshift.io/v1 + kind: ImageStream + metadata: + name: publicapi-indexer-production + labels: + app: publicapi-indexer-production + spec: + lookupPolicy: + local: true + + # BuildConfig using Docker build strategy + - apiVersion: build.openshift.io/v1 + kind: BuildConfig + metadata: + name: publicapi-indexer-build-production + labels: + app: publicapi-indexer-production + spec: + source: + git: + uri: https://github.com/CSCfi/research-fi-publicapi.git + ref: main + contextDir: . + strategy: + type: Docker + dockerStrategy: + dockerfilePath: aspnetcore/openshift/indexer/rahti2/Dockerfile + output: + to: + kind: ImageStreamTag + name: publicapi-indexer-production:latest + successfulBuildsHistoryLimit: 2 + failedBuildsHistoryLimit: 2 diff --git a/aspnetcore/openshift/indexer/rahti2/template-indexer-app-qa.yml b/aspnetcore/openshift/indexer/rahti2/template-indexer-app-qa.yml new file mode 100644 index 0000000..1206cab --- /dev/null +++ b/aspnetcore/openshift/indexer/rahti2/template-indexer-app-qa.yml @@ -0,0 +1,52 @@ +# This file is part of the research.fi api +# +# Copyright 2024 Ministry of Education and Culture, Finland +# +# :author: CSC - IT Center for Science Ltd., Espoo Finland servicedesk@csc.fi +# :license: MIT +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + labels: + app: publicapi-indexer-qa + template: publicapi-indexer-qa + name: publicapi-indexer-qa + annotations: + description: "Public API indexer QA - Build and ImageStream" + iconClass: icon-dotnet +objects: + + # ImageStream + - apiVersion: image.openshift.io/v1 + kind: ImageStream + metadata: + name: publicapi-indexer-qa + labels: + app: publicapi-indexer-qa + spec: + lookupPolicy: + local: true + + # BuildConfig using Docker build strategy + - apiVersion: build.openshift.io/v1 + kind: BuildConfig + metadata: + name: publicapi-indexer-build-qa + labels: + app: publicapi-indexer-qa + spec: + source: + git: + uri: https://github.com/CSCfi/research-fi-publicapi.git + ref: qa + contextDir: . + strategy: + type: Docker + dockerStrategy: + dockerfilePath: aspnetcore/openshift/indexer/rahti2/Dockerfile + output: + to: + kind: ImageStreamTag + name: publicapi-indexer-qa:latest + successfulBuildsHistoryLimit: 2 + failedBuildsHistoryLimit: 2 diff --git a/aspnetcore/openshift/indexer/rahti2/template-indexer-cronjob-devel.yml b/aspnetcore/openshift/indexer/rahti2/template-indexer-cronjob-devel.yml new file mode 100644 index 0000000..63feb83 --- /dev/null +++ b/aspnetcore/openshift/indexer/rahti2/template-indexer-cronjob-devel.yml @@ -0,0 +1,53 @@ +# This file is part of the research.fi api +# +# Copyright 2024 Ministry of Education and Culture, Finland +# +# :author: CSC - IT Center for Science Ltd., Espoo Finland servicedesk@csc.fi +# :license: MIT +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + labels: + app: publicapi-indexer-devel + template: publicapi-indexer-cronjob-devel + name: publicapi-indexer-cronjob-devel + annotations: + description: "Public API indexer devel - CronJob" + iconClass: icon-dotnet +objects: + # Recurring CronJob (devel) + # Indexes db entities to ElasticSearch. + - apiVersion: batch/v1 + kind: CronJob + metadata: + name: publicapi-indexer-cronjob-devel + spec: + schedule: "0 1 * * *" # every day at 01:00 UTC + concurrencyPolicy: "Forbid" + startingDeadlineSeconds: 300 # Can start 5 minutes after the schedule + suspend: false + successfulJobsHistoryLimit: 2 + failedJobsHistoryLimit: 2 + jobTemplate: + spec: + activeDeadlineSeconds: 2400 # Can run for 40 minutes + template: + spec: + restartPolicy: Never + containers: + - name: publicapi-indexer-container-devel + image: publicapi-indexer-devel + imagePullPolicy: Always + envFrom: + - secretRef: + name: publicapi-api-secret-devel + - configMapRef: + name: publicapi-api-config-devel + resources: + limits: + cpu: 500m + memory: 2Gi + requests: + cpu: 100m + memory: 512Mi + \ No newline at end of file diff --git a/aspnetcore/openshift/indexer/rahti2/template-indexer-cronjob-production.yml b/aspnetcore/openshift/indexer/rahti2/template-indexer-cronjob-production.yml new file mode 100644 index 0000000..84c9733 --- /dev/null +++ b/aspnetcore/openshift/indexer/rahti2/template-indexer-cronjob-production.yml @@ -0,0 +1,53 @@ +# This file is part of the research.fi api +# +# Copyright 2024 Ministry of Education and Culture, Finland +# +# :author: CSC - IT Center for Science Ltd., Espoo Finland servicedesk@csc.fi +# :license: MIT +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + labels: + app: publicapi-indexer-production + template: publicapi-indexer-cronjob-production + name: publicapi-indexer-cronjob-production + annotations: + description: "Public API indexer production - CronJob" + iconClass: icon-dotnet +objects: + # Recurring CronJob (production) + # Indexes db entities to ElasticSearch. + - apiVersion: batch/v1 + kind: CronJob + metadata: + name: publicapi-indexer-cronjob-production + spec: + schedule: "40 19 * * *" # every day at 19:40 UTC + concurrencyPolicy: "Forbid" + startingDeadlineSeconds: 300 # Can start 5 minutes after the schedule + suspend: false + successfulJobsHistoryLimit: 2 + failedJobsHistoryLimit: 2 + jobTemplate: + spec: + activeDeadlineSeconds: 2400 # Can run for 40 minutes + template: + spec: + restartPolicy: Never + containers: + - name: publicapi-indexer-container-production + image: publicapi-indexer-production + imagePullPolicy: Always + envFrom: + - secretRef: + name: publicapi-api-secret-production + - configMapRef: + name: publicapi-api-config-production + resources: + limits: + cpu: 500m + memory: 3Gi + requests: + cpu: 100m + memory: 1Gi + \ No newline at end of file diff --git a/aspnetcore/openshift/indexer/rahti2/template-indexer-cronjob-qa.yml b/aspnetcore/openshift/indexer/rahti2/template-indexer-cronjob-qa.yml new file mode 100644 index 0000000..5d124ae --- /dev/null +++ b/aspnetcore/openshift/indexer/rahti2/template-indexer-cronjob-qa.yml @@ -0,0 +1,53 @@ +# This file is part of the research.fi api +# +# Copyright 2024 Ministry of Education and Culture, Finland +# +# :author: CSC - IT Center for Science Ltd., Espoo Finland servicedesk@csc.fi +# :license: MIT +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + labels: + app: publicapi-indexer-qa + template: publicapi-indexer-cronjob-qa + name: publicapi-indexer-cronjob-qa + annotations: + description: "Public API indexer QA - CronJob" + iconClass: icon-dotnet +objects: + # Recurring CronJob (qa) + # Indexes db entities to ElasticSearch. + - apiVersion: batch/v1 + kind: CronJob + metadata: + name: publicapi-indexer-cronjob-qa + spec: + schedule: "0 2 * * *" # every day at 02:00 UTC + concurrencyPolicy: "Forbid" + startingDeadlineSeconds: 300 # Can start 5 minutes after the schedule + suspend: false + successfulJobsHistoryLimit: 2 + failedJobsHistoryLimit: 2 + jobTemplate: + spec: + activeDeadlineSeconds: 2400 # Can run for 40 minutes + template: + spec: + restartPolicy: Never + containers: + - name: publicapi-indexer-container-qa + image: publicapi-indexer-qa + imagePullPolicy: Always + envFrom: + - secretRef: + name: publicapi-api-secret-qa + - configMapRef: + name: publicapi-api-config-qa + resources: + limits: + cpu: 500m + memory: 3Gi + requests: + cpu: 100m + memory: 1Gi + \ No newline at end of file diff --git a/aspnetcore/openshift/indexer/rahti2/template-indexer-manualjob-devel.yml b/aspnetcore/openshift/indexer/rahti2/template-indexer-manualjob-devel.yml new file mode 100644 index 0000000..a3cd352 --- /dev/null +++ b/aspnetcore/openshift/indexer/rahti2/template-indexer-manualjob-devel.yml @@ -0,0 +1,47 @@ +# This file is part of the research.fi api +# +# Copyright 2024 Ministry of Education and Culture, Finland +# +# :author: CSC - IT Center for Science Ltd., Espoo Finland servicedesk@csc.fi +# :license: MIT +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + labels: + app: publicapi-indexer-devel + template: publicapi-indexer-manualjob-devel + name: publicapi-indexer-manualjob-devel + annotations: + description: "Public API indexer devel - single-run Job" + iconClass: icon-dotnet +objects: + # Single-run Job (devel) + # Use this job to index entities to ElasticSearch manually when needed. + - apiVersion: batch/v1 + kind: Job + metadata: + name: publicapi-indexer-manualjob-devel + labels: + app: publicapi-indexer-devel + annotations: + description: Public API indexer devel - single-run Job + spec: + template: + spec: + restartPolicy: Never + containers: + - name: publicapi-indexer-manualjob-container-devel + image: publicapi-indexer-devel + imagePullPolicy: Always + envFrom: + - secretRef: + name: publicapi-api-secret-devel + - configMapRef: + name: publicapi-api-config-devel + resources: + limits: + cpu: 500m + memory: 2Gi + requests: + cpu: 100m + memory: 512Mi diff --git a/aspnetcore/openshift/indexer/rahti2/template-indexer-manualjob-production.yml b/aspnetcore/openshift/indexer/rahti2/template-indexer-manualjob-production.yml new file mode 100644 index 0000000..67f2197 --- /dev/null +++ b/aspnetcore/openshift/indexer/rahti2/template-indexer-manualjob-production.yml @@ -0,0 +1,47 @@ +# This file is part of the research.fi api +# +# Copyright 2023 Ministry of Education and Culture, Finland +# +# :author: CSC - IT Center for Science Ltd., Espoo Finland servicedesk@csc.fi +# :license: MIT +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + labels: + app: publicapi-indexer-production + template: publicapi-indexer-manualjob-production + name: publicapi-indexer-manualjob-production + annotations: + description: "Public API indexer production - single-run Job" + iconClass: icon-dotnet +objects: + # Single-run Job (production) + # Use this job to index entities to ElasticSearch manually when needed. + - apiVersion: batch/v1 + kind: Job + metadata: + name: publicapi-indexer-manualjob-production + labels: + app: publicapi-indexer-production + annotations: + description: Public API indexer production - single-run Job + spec: + template: + spec: + restartPolicy: Never + containers: + - name: publicapi-indexer-manualjob-container-production + image: publicapi-indexer-production + imagePullPolicy: Always + envFrom: + - secretRef: + name: publicapi-api-secret-production + - configMapRef: + name: publicapi-api-config-production + resources: + limits: + cpu: 500m + memory: 3Gi + requests: + cpu: 100m + memory: 1Gi diff --git a/aspnetcore/openshift/indexer/rahti2/template-indexer-manualjob-qa.yml b/aspnetcore/openshift/indexer/rahti2/template-indexer-manualjob-qa.yml new file mode 100644 index 0000000..7d85404 --- /dev/null +++ b/aspnetcore/openshift/indexer/rahti2/template-indexer-manualjob-qa.yml @@ -0,0 +1,47 @@ +# This file is part of the research.fi api +# +# Copyright 2023 Ministry of Education and Culture, Finland +# +# :author: CSC - IT Center for Science Ltd., Espoo Finland servicedesk@csc.fi +# :license: MIT +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + labels: + app: publicapi-indexer-qa + template: publicapi-indexer-manualjob-qa + name: publicapi-indexer-manualjob-qa + annotations: + description: "Public API indexer QA - single-run Job" + iconClass: icon-dotnet +objects: + # Single-run Job (qa) + # Use this job to index entities to ElasticSearch manually when needed. + - apiVersion: batch/v1 + kind: Job + metadata: + name: publicapi-indexer-manualjob-qa + labels: + app: publicapi-indexer-qa + annotations: + description: Public API indexer QA - single-run Job + spec: + template: + spec: + restartPolicy: Never + containers: + - name: publicapi-indexer-manualjob-container-qa + image: publicapi-indexer-qa + imagePullPolicy: Always + envFrom: + - secretRef: + name: publicapi-api-secret-qa + - configMapRef: + name: publicapi-api-config-qa + resources: + limits: + cpu: 500m + memory: 3Gi + requests: + cpu: 100m + memory: 1Gi