diff --git a/aspnetcore/openshift/api/rahti2/Dockerfile b/aspnetcore/openshift/api/rahti2/Dockerfile new file mode 100644 index 00000000..919ef756 --- /dev/null +++ b/aspnetcore/openshift/api/rahti2/Dockerfile @@ -0,0 +1,20 @@ +# Builder +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env +WORKDIR /app +# Copy csproj and restore as distinct layers +COPY aspnetcore/custom_nuget/ /app/custom_nuget +COPY aspnetcore/nuget.config ./ +COPY aspnetcore/src/api/api.csproj ./ +RUN dotnet restore +# Copy everything else and build +COPY aspnetcore/src/api/ ./ +RUN dotnet publish -c Release -o out + + + +# Runtime image +FROM mcr.microsoft.com/dotnet/aspnet:6.0 +WORKDIR /app +COPY --from=build-env /app/out . +EXPOSE 8080 +ENTRYPOINT ["dotnet", "api.dll"] diff --git a/aspnetcore/openshift/api/rahti2/template-api-devel.yml b/aspnetcore/openshift/api/rahti2/template-api-devel.yml new file mode 100644 index 00000000..fd1cdfac --- /dev/null +++ b/aspnetcore/openshift/api/rahti2/template-api-devel.yml @@ -0,0 +1,130 @@ +# This file is part of the research.fi service +# +# 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: mydata-api-devel + template: mydata-api-devel + name: mydata-api-devel + annotations: + description: "Mydata backend devel" + iconClass: icon-dotnet +objects: + + # Service + - apiVersion: v1 + kind: Service + metadata: + name: mydata-api-devel + labels: + app: mydata-api-devel + annotations: + description: Mydata backend devel + spec: + ports: + - name: dotnet + port: 8080 + targetPort: 8080 + selector: + app: mydata-api-devel + + # Route + - apiVersion: route.openshift.io/v1 + kind: Route + metadata: + name: mydata-api-devel + labels: + app: mydata-api-devel + spec: + host: mydata-api-devel.2.rahtiapp.fi + to: + kind: Service + name: mydata-api-devel + weight: 100 + port: + targetPort: dotnet + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + wildcardPolicy: None + + # ImageStream + - apiVersion: image.openshift.io/v1 + kind: ImageStream + metadata: + name: mydata-api-devel + labels: + app: mydata-api-devel + + # BuildConfig using Docker build strategy + - apiVersion: build.openshift.io/v1 + kind: BuildConfig + metadata: + name: mydata-api-build-devel + labels: + app: mydata-api-devel + spec: + source: + git: + uri: https://github.com/CSCfi/research-fi-mydata.git + ref: devel + contextDir: . + strategy: + type: Docker + dockerStrategy: + dockerfilePath: aspnetcore/openshift/api/rahti2/Dockerfile + output: + to: + kind: ImageStreamTag + name: mydata-api-devel:latest + successfulBuildsHistoryLimit: 2 + failedBuildsHistoryLimit: 2 + + # Deployment + - apiVersion: apps/v1 + kind: Deployment + metadata: + name: mydata-api-devel + labels: + app: mydata-api-devel + spec: + selector: + matchLabels: + app: mydata-api-devel + template: + metadata: + labels: + app: mydata-api-devel + spec: + containers: + - name: mydata-api-container-devel + image: image-registry.openshift-image-registry.svc:5000/researchfi-devel/mydata-api-devel:latest + imagePullPolicy: Always + ports: + - containerPort: 8080 + protocol: TCP + resources: + limits: + cpu: 500m + memory: 4Gi + requests: + cpu: 100m + memory: 1Gi + replicas: 1 + triggers: + - type: ConfigChange + - type: ImageChange + imageChangeParams: + automatic: true + containerNames: + - mydata-api-container-devel + from: + kind: ImageStreamTag + name: mydata-api-devel:latest + strategy: + type: RollingUpdate \ No newline at end of file diff --git a/aspnetcore/openshift/api/rahti2/template-api-production.yml b/aspnetcore/openshift/api/rahti2/template-api-production.yml new file mode 100644 index 00000000..ddb56dc8 --- /dev/null +++ b/aspnetcore/openshift/api/rahti2/template-api-production.yml @@ -0,0 +1,130 @@ +# This file is part of the research.fi service +# +# 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: mydata-api-production + template: mydata-api-production + name: mydata-api-production + annotations: + description: "Mydata backend production" + iconClass: icon-dotnet +objects: + + # Service + - apiVersion: v1 + kind: Service + metadata: + name: mydata-api-production + labels: + app: mydata-api-production + annotations: + description: Mydata backend production + spec: + ports: + - name: dotnet + port: 8080 + targetPort: 8080 + selector: + app: mydata-api-production + + # Route + - apiVersion: route.openshift.io/v1 + kind: Route + metadata: + name: mydata-api-production + labels: + app: mydata-api-production + spec: + host: mydata-api-production.2.rahtiapp.fi + to: + kind: Service + name: mydata-api-production + weight: 100 + port: + targetPort: dotnet + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + wildcardPolicy: None + + # ImageStream + - apiVersion: image.openshift.io/v1 + kind: ImageStream + metadata: + name: mydata-api-production + labels: + app: mydata-api-production + + # BuildConfig using Docker build strategy + - apiVersion: build.openshift.io/v1 + kind: BuildConfig + metadata: + name: mydata-api-build-production + labels: + app: mydata-api-production + spec: + source: + git: + uri: https://github.com/CSCfi/research-fi-mydata.git + ref: master + contextDir: . + strategy: + type: Docker + dockerStrategy: + dockerfilePath: aspnetcore/openshift/api/rahti2/Dockerfile + output: + to: + kind: ImageStreamTag + name: mydata-api-production:latest + successfulBuildsHistoryLimit: 2 + failedBuildsHistoryLimit: 2 + + # Deployment + - apiVersion: apps/v1 + kind: Deployment + metadata: + name: mydata-api-production + labels: + app: mydata-api-production + spec: + selector: + matchLabels: + app: mydata-api-production + template: + metadata: + labels: + app: mydata-api-production + spec: + containers: + - name: mydata-api-container-production + image: image-registry.openshift-image-registry.svc:5000/researchfi-production/mydata-api-production:latest + imagePullPolicy: Always + ports: + - containerPort: 8080 + protocol: TCP + resources: + limits: + cpu: 1 + memory: 8Gi + requests: + cpu: 500m + memory: 4Gi + replicas: 1 + triggers: + - type: ConfigChange + - type: ImageChange + imageChangeParams: + automatic: true + containerNames: + - mydata-api-container-production + from: + kind: ImageStreamTag + name: mydata-api-production:latest + strategy: + type: RollingUpdate \ No newline at end of file diff --git a/aspnetcore/openshift/api/rahti2/template-api-qa.yml b/aspnetcore/openshift/api/rahti2/template-api-qa.yml new file mode 100644 index 00000000..9822f4f4 --- /dev/null +++ b/aspnetcore/openshift/api/rahti2/template-api-qa.yml @@ -0,0 +1,130 @@ +# This file is part of the research.fi service +# +# 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: mydata-api-qa + template: mydata-api-qa + name: mydata-api-qa + annotations: + description: "Mydata backend QA" + iconClass: icon-dotnet +objects: + + # Service + - apiVersion: v1 + kind: Service + metadata: + name: mydata-api-qa + labels: + app: mydata-api-qa + annotations: + description: Mydata backend QA + spec: + ports: + - name: dotnet + port: 8080 + targetPort: 8080 + selector: + app: mydata-api-qa + + # Route + - apiVersion: route.openshift.io/v1 + kind: Route + metadata: + name: mydata-api-qa + labels: + app: mydata-api-qa + spec: + host: mydata-api-qa.2.rahtiapp.fi + to: + kind: Service + name: mydata-api-qa + weight: 100 + port: + targetPort: dotnet + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + wildcardPolicy: None + + # ImageStream + - apiVersion: image.openshift.io/v1 + kind: ImageStream + metadata: + name: mydata-api-qa + labels: + app: mydata-api-qa + + # BuildConfig using Docker build strategy + - apiVersion: build.openshift.io/v1 + kind: BuildConfig + metadata: + name: mydata-api-build-qa + labels: + app: mydata-api-qa + spec: + source: + git: + uri: https://github.com/CSCfi/research-fi-mydata.git + ref: qa + contextDir: . + strategy: + type: Docker + dockerStrategy: + dockerfilePath: aspnetcore/openshift/api/rahti2/Dockerfile + output: + to: + kind: ImageStreamTag + name: mydata-api-qa:latest + successfulBuildsHistoryLimit: 2 + failedBuildsHistoryLimit: 2 + + # Deployment + - apiVersion: apps/v1 + kind: Deployment + metadata: + name: mydata-api-qa + labels: + app: mydata-api-qa + spec: + selector: + matchLabels: + app: mydata-api-qa + template: + metadata: + labels: + app: mydata-api-qa + spec: + containers: + - name: mydata-api-container-qa + image: image-registry.openshift-image-registry.svc:5000/researchfi-qa/mydata-api-qa:latest + imagePullPolicy: Always + ports: + - containerPort: 8080 + protocol: TCP + resources: + limits: + cpu: 500m + memory: 6Gi + requests: + cpu: 100m + memory: 2Gi + replicas: 1 + triggers: + - type: ConfigChange + - type: ImageChange + imageChangeParams: + automatic: true + containerNames: + - mydata-api-container-qa + from: + kind: ImageStreamTag + name: mydata-api-qa:latest + strategy: + type: RollingUpdate \ No newline at end of file