diff --git a/aspnetcore/openshift/api/rahti2/Dockerfile b/aspnetcore/openshift/api/rahti2/Dockerfile new file mode 100644 index 0000000..ec9ebd8 --- /dev/null +++ b/aspnetcore/openshift/api/rahti2/Dockerfile @@ -0,0 +1,28 @@ +# 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","./Interface/nuget.config"] +COPY ["aspnetcore/src/Interface/Interface.csproj","./Interface/Interface.csproj"] +COPY ["aspnetcore/src/ElasticService/ElasticService.csproj","./ElasticService/ElasticService.csproj"] +COPY ["aspnetcore/src/Service.Models/Service.Models.csproj","./Service.Models/Service.Models.csproj"] +COPY ["aspnetcore/src/ApiModels/ApiModels.csproj","./ApiModels/ApiModels.csproj"] +COPY ["aspnetcore/src/Logging/Logging.csproj","./Logging/Logging.csproj"] +RUN dotnet restore "Interface/Interface.csproj" + +# Copy everything else and build +COPY ["aspnetcore/src/Interface/","./Interface"] +COPY ["aspnetcore/src/ElasticService/","./ElasticService"] +COPY ["aspnetcore/src/Service.Models/","./Service.Models"] +COPY ["aspnetcore/src/ApiModels/","./ApiModels"] +COPY ["aspnetcore/src/Logging/","./Logging"] +RUN dotnet publish "Interface/Interface.csproj" -c Release -o out + +# Runtime image +FROM mcr.microsoft.com/dotnet/aspnet:6.0 +WORKDIR /app +COPY --from=build-env /build/out . +EXPOSE 8080 +ENTRYPOINT ["dotnet", "CSC.PublicApi.Interface.dll"] \ No newline at end of file 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 0000000..ae4be47 --- /dev/null +++ b/aspnetcore/openshift/api/rahti2/template-api-devel.yml @@ -0,0 +1,110 @@ +# 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-api-devel + template: publicapi-api-devel + name: publicapi-api-devel + annotations: + description: "Public API devel" + iconClass: icon-dotnet +objects: + + # Service + - apiVersion: v1 + kind: Service + metadata: + name: publicapi-api-devel + labels: + app: publicapi-api-devel + annotations: + description: Public API devel + spec: + ports: + - name: dotnet + port: 8080 + targetPort: 8080 + selector: + app: publicapi-api-devel + + # ImageStream + - apiVersion: image.openshift.io/v1 + kind: ImageStream + metadata: + name: publicapi-api-devel + labels: + app: publicapi-api-devel + + # BuildConfig using Docker build strategy + - apiVersion: build.openshift.io/v1 + kind: BuildConfig + metadata: + name: publicapi-api-build-devel + labels: + app: publicapi-api-devel + spec: + source: + git: + uri: https://github.com/CSCfi/research-fi-publicapi.git + ref: devel + contextDir: . + strategy: + type: Docker + dockerStrategy: + dockerfilePath: aspnetcore/openshift/api/rahti2/Dockerfile + output: + to: + kind: ImageStreamTag + name: publicapi-api-devel:latest + successfulBuildsHistoryLimit: 2 + failedBuildsHistoryLimit: 2 + + # Deployment config + - apiVersion: apps/v1 + kind: Deployment + metadata: + name: publicapi-api-devel + labels: + app: publicapi-api-devel + spec: + selector: + matchLabels: + app: publicapi-api-devel + template: + metadata: + labels: + app: publicapi-api-devel + spec: + containers: + - name: publicapi-api-container-devel + image: image-registry.openshift-image-registry.svc:5000/researchfi-devel/publicapi-api-devel:latest + imagePullPolicy: Always + ports: + - containerPort: 8080 + protocol: TCP + resources: + limits: + cpu: 250m + memory: 256Mi + requests: + cpu: 50m + memory: 128Mi + replicas: 1 + triggers: + - type: ConfigChange + - type: ImageChange + imageChangeParams: + automatic: true + containerNames: + - publicapi-api-container-devel + from: + kind: ImageStreamTag + name: publicapi-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 0000000..418a4e4 --- /dev/null +++ b/aspnetcore/openshift/api/rahti2/template-api-production.yml @@ -0,0 +1,110 @@ +# 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-api-production + template: publicapi-api-production + name: publicapi-api-production + annotations: + description: "Public API production" + iconClass: icon-dotnet +objects: + + # Service + - apiVersion: v1 + kind: Service + metadata: + name: publicapi-api-production + labels: + app: publicapi-api-production + annotations: + description: Public API production + spec: + ports: + - name: dotnet + port: 8080 + targetPort: 8080 + selector: + app: publicapi-api-production + + # ImageStream + - apiVersion: image.openshift.io/v1 + kind: ImageStream + metadata: + name: publicapi-api-production + labels: + app: publicapi-api-production + + # BuildConfig using Docker build strategy + - apiVersion: build.openshift.io/v1 + kind: BuildConfig + metadata: + name: publicapi-api-build-production + labels: + app: publicapi-api-production + spec: + source: + git: + uri: https://github.com/CSCfi/research-fi-publicapi.git + ref: main + contextDir: . + strategy: + type: Docker + dockerStrategy: + dockerfilePath: aspnetcore/openshift/api/rahti2/Dockerfile + output: + to: + kind: ImageStreamTag + name: publicapi-api-production:latest + successfulBuildsHistoryLimit: 2 + failedBuildsHistoryLimit: 2 + + # Deployment config + - apiVersion: apps/v1 + kind: Deployment + metadata: + name: publicapi-api-production + labels: + app: publicapi-api-production + spec: + selector: + matchLabels: + app: publicapi-api-production + template: + metadata: + labels: + app: publicapi-api-production + spec: + containers: + - name: publicapi-api-container-production + image: image-registry.openshift-image-registry.svc:5000/researchfi-production/publicapi-api-production:latest + imagePullPolicy: Always + ports: + - containerPort: 8080 + protocol: TCP + resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 100m + memory: 256Mi + replicas: 1 + triggers: + - type: ConfigChange + - type: ImageChange + imageChangeParams: + automatic: true + containerNames: + - publicapi-api-container-production + from: + kind: ImageStreamTag + name: publicapi-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 0000000..2ef8256 --- /dev/null +++ b/aspnetcore/openshift/api/rahti2/template-api-qa.yml @@ -0,0 +1,110 @@ +# 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-api-qa + template: publicapi-api-qa + name: publicapi-api-qa + annotations: + description: "Public API QA" + iconClass: icon-dotnet +objects: + + # Service + - apiVersion: v1 + kind: Service + metadata: + name: publicapi-api-qa + labels: + app: publicapi-api-qa + annotations: + description: Public API QA + spec: + ports: + - name: dotnet + port: 8080 + targetPort: 8080 + selector: + app: publicapi-api-qa + + # ImageStream + - apiVersion: image.openshift.io/v1 + kind: ImageStream + metadata: + name: publicapi-api-qa + labels: + app: publicapi-api-qa + + # BuildConfig using Docker build strategy + - apiVersion: build.openshift.io/v1 + kind: BuildConfig + metadata: + name: publicapi-api-build-qa + labels: + app: publicapi-api-qa + spec: + source: + git: + uri: https://github.com/CSCfi/research-fi-publicapi.git + ref: qa + contextDir: . + strategy: + type: Docker + dockerStrategy: + dockerfilePath: aspnetcore/openshift/api/rahti2/Dockerfile + output: + to: + kind: ImageStreamTag + name: publicapi-api-qa:latest + successfulBuildsHistoryLimit: 2 + failedBuildsHistoryLimit: 2 + + # Deployment config + - apiVersion: apps/v1 + kind: Deployment + metadata: + name: publicapi-api-qa + labels: + app: publicapi-api-qa + spec: + selector: + matchLabels: + app: publicapi-api-qa + template: + metadata: + labels: + app: publicapi-api-qa + spec: + containers: + - name: publicapi-api-container-qa + image: image-registry.openshift-image-registry.svc:5000/researchfi-qa/publicapi-api-qa:latest + imagePullPolicy: Always + ports: + - containerPort: 8080 + protocol: TCP + resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 100m + memory: 256Mi + replicas: 1 + triggers: + - type: ConfigChange + - type: ImageChange + imageChangeParams: + automatic: true + containerNames: + - publicapi-api-container-qa + from: + kind: ImageStreamTag + name: publicapi-api-qa:latest + strategy: + type: RollingUpdate \ No newline at end of file