Template
chore: deploy initial code base
This commit is contained in:
+284
@@ -0,0 +1,284 @@
|
||||
ARG PROJECT=Strata.ContinuousImprovement
|
||||
ARG DSPROJECT=Strata.DecisionSupport
|
||||
ARG VERSION=0.0.0
|
||||
ARG SONARURL=''
|
||||
ARG SONARLOGIN=''
|
||||
ARG SONARBRANCH=''
|
||||
|
||||
##############
|
||||
# Base image #
|
||||
##############
|
||||
FROM ecr.ops.stratanetwork.net/strata.microsoft.dotnet.aspnet:8.0 AS base
|
||||
|
||||
# Add TMZ files for CST
|
||||
RUN cp /usr/share/zoneinfo/America/Chicago "/usr/share/zoneinfo/Central Standard Time"
|
||||
|
||||
RUN sed -i 's/^Components: main$/& contrib/' /etc/apt/sources.list.d/debian.sources \
|
||||
&& apt-get -qq update --allow-releaseinfo-change \
|
||||
&& apt-get -qq install -y \
|
||||
libc6 \
|
||||
libc6-dev \
|
||||
libgdiplus \
|
||||
libx11-dev \
|
||||
ttf-mscorefonts-installer \
|
||||
fontconfig \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& ln -s /usr/lib/x86_64-linux-gnu/libdl.so.2 /usr/lib/x86_64-linux-gnu/libdl.so
|
||||
|
||||
###############
|
||||
# Build image #
|
||||
###############
|
||||
FROM ecr.ops.stratanetwork.net/strata.microsoft.dotnet.sdk:8.0 AS build
|
||||
ARG PROJECT
|
||||
ARG DSPROJECT
|
||||
ARG VERSION
|
||||
ARG SONARURL
|
||||
ARG SONARLOGIN
|
||||
ARG SONARBRANCH
|
||||
|
||||
# Add TMZ files for CST
|
||||
RUN cp /usr/share/zoneinfo/America/Chicago "/usr/share/zoneinfo/Central Standard Time"
|
||||
|
||||
RUN sed -i 's/^Components: main$/& contrib/' /etc/apt/sources.list.d/debian.sources \
|
||||
&& apt-get -qq update --allow-releaseinfo-change \
|
||||
&& apt-get -qq install -y \
|
||||
libc6 \
|
||||
libc6-dev \
|
||||
libgdiplus \
|
||||
libx11-dev \
|
||||
ttf-mscorefonts-installer \
|
||||
fontconfig \
|
||||
awscli \
|
||||
jq \
|
||||
&& rm -rf /var/lib/apt/lists/*\
|
||||
&& ln -s /usr/lib/x86_64-linux-gnu/libdl.so.2 /usr/lib/x86_64-linux-gnu/libdl.so
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
|
||||
# Copy project files and restore
|
||||
COPY ["${PROJECT}.sln", "${PROJECT}.sln"]
|
||||
COPY src/**/*.csproj ./
|
||||
RUN for file in $(ls *.csproj); do mkdir -p src/${file%.*}/ && mv $file src/${file%.*}/; done
|
||||
COPY tests/**/*.csproj ./
|
||||
RUN for file in $(ls *.csproj); do mkdir -p tests/${file%.*}/ && mv $file tests/${file%.*}/; done
|
||||
|
||||
RUN dotnet restore "${PROJECT}.sln" \
|
||||
--source https://api.nuget.org/v3/index.json \
|
||||
--source https://proget.sdt.local/nuget/nuget/v3/index.json
|
||||
|
||||
|
||||
# Copy files and build
|
||||
COPY . .
|
||||
|
||||
RUN if [ "${SONARLOGIN}" != "" ] ; then dotnet sonarscanner begin \
|
||||
/k:"${PROJECT}" \
|
||||
/d:sonar.scm.provider=git \
|
||||
/d:sonar.host.url="${SONARURL}" \
|
||||
${SONARBRANCH} \
|
||||
/d:sonar.login="${SONARLOGIN}" \
|
||||
/d:sonar.cs.opencover.reportsPaths="/test-results/cover.xml" \
|
||||
/d:sonar.cs.vstest.reportsPaths="/test-results/*.trx" \
|
||||
/d:sonar.dependencyCheck.jsonReportPath=/src/buildlogs/dependency-check-report.json \
|
||||
/d:sonar.dependencyCheck.htmlReportPath=/src/buildlogs/dependency-check-report.html \
|
||||
/v:sonar.projectVersion="${VERSION}"; fi
|
||||
|
||||
|
||||
RUN dotnet build "${PROJECT}.sln" \
|
||||
--configuration Release \
|
||||
--no-restore
|
||||
|
||||
# Run tests
|
||||
# #############################
|
||||
# # ContinuousImprovement Api #
|
||||
# #############################
|
||||
|
||||
RUN dotnet test "tests/${PROJECT}.Api.Test.Unit/${PROJECT}.Api.Test.Unit.csproj" \
|
||||
--configuration Release \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--verbosity=normal \
|
||||
--logger="trx;LogFileName=/test-results/api-api-tests.trx" \
|
||||
-p:CollectCoverage=true \
|
||||
-p:CoverletOutput='/test-results/' \
|
||||
-p:Exclude=\"[Strata.ContinuousImprovement.Biz.Test.Unit]*,[Strata.ContinuousImprovement.JazzEntityFrameworkStub]*\"
|
||||
|
||||
RUN CREDS=$(aws sts assume-role --role-arn arn:aws:iam::809820578507:role/sdt-continuous-improvement-service-role --role-session-name "DockerBuildSession"); \
|
||||
export AWS_ACCESS_KEY_ID="$(echo $CREDS | jq -r '.Credentials.AccessKeyId')"; \
|
||||
export AWS_SECRET_ACCESS_KEY="$(echo $CREDS | jq -r '.Credentials.SecretAccessKey')"; \
|
||||
export AWS_SESSION_TOKEN="$(echo $CREDS | jq -r '.Credentials.SessionToken')"; \
|
||||
dotnet test "tests/${PROJECT}.Api.Test.Integration/${PROJECT}.Api.Test.Integration.csproj" \
|
||||
--configuration Release \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--verbosity=normal \
|
||||
--logger="trx;LogFileName=/test-results/integration-tests-api.trx" \
|
||||
-p:CollectCoverage=true \
|
||||
-p:CoverletOutputFormat=opencover \
|
||||
-p:CoverletOutput='/test-results/' \
|
||||
-p:MergeWith='/test-results/coverage.json' \
|
||||
-p:Exclude=\"[Strata.ContinuousImprovement.Api.Test.Unit]*,[Strata.ContinuousImprovement.JazzEntityFrameworkStub]*\"
|
||||
|
||||
# #############################
|
||||
# # ContinuousImprovement Biz #
|
||||
# #############################
|
||||
|
||||
RUN dotnet test "/src/tests/${PROJECT}.Biz.Test.Unit/${PROJECT}.Biz.Test.Unit.csproj" \
|
||||
--configuration Release \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--verbosity=normal \
|
||||
--logger="trx;LogFileName=/test-results/unit-tests-biz.trx" \
|
||||
-p:CollectCoverage=true \
|
||||
-p:CoverletOutput='/test-results/' \
|
||||
-p:MergeWith='/test-results/coverage.json' \
|
||||
-p:Exclude=\"[Strata.ContinuousImprovement.Biz.Test.Unit]*,[Strata.ContinuousImprovement.JazzEntityFrameworkStub]*\"
|
||||
|
||||
RUN CREDS=$(aws sts assume-role --role-arn arn:aws:iam::809820578507:role/sdt-continuous-improvement-service-role --role-session-name "DockerBuildSession"); \
|
||||
export AWS_ACCESS_KEY_ID="$(echo $CREDS | jq -r '.Credentials.AccessKeyId')"; \
|
||||
export AWS_SECRET_ACCESS_KEY="$(echo $CREDS | jq -r '.Credentials.SecretAccessKey')"; \
|
||||
export AWS_SESSION_TOKEN="$(echo $CREDS | jq -r '.Credentials.SessionToken')"; \
|
||||
dotnet test "tests/${PROJECT}.Biz.Test.Integration/${PROJECT}.Biz.Test.Integration.csproj" \
|
||||
--configuration Release \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--verbosity=normal \
|
||||
--logger="trx;LogFileName=/test-results/integration-tests-biz.trx" \
|
||||
-p:CollectCoverage=true \
|
||||
-p:CoverletOutputFormat=opencover \
|
||||
-p:CoverletOutput='/test-results/' \
|
||||
-p:MergeWith='/test-results/coverage.json' \
|
||||
-p:Exclude=\"[Strata.ContinuousImprovement.Biz.Test.Unit]*,[Strata.ContinuousImprovement.JazzEntityFrameworkStub]*\"
|
||||
|
||||
# ################################
|
||||
# # ContinuousImprovement Client #
|
||||
# ################################
|
||||
|
||||
RUN dotnet test "tests/${PROJECT}.Client.Test.Unit/${PROJECT}.Client.Test.Unit.csproj" \
|
||||
--configuration Release \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--verbosity=normal \
|
||||
--logger="trx;LogFileName=/test-results/unit-tests-client.trx" \
|
||||
-p:CollectCoverage=true \
|
||||
-p:CoverletOutputFormat=opencover \
|
||||
-p:CoverletOutput='/test-results/' \
|
||||
-p:MergeWith='/test-results/coverage.json' \
|
||||
-p:Exclude=\"[Strata.ContinuousImprovement.Client.Test.Unit]*,[Strata.ContinuousImprovement.JazzEntityFrameworkStub]*\"
|
||||
|
||||
RUN CREDS=$(aws sts assume-role --role-arn arn:aws:iam::809820578507:role/sdt-continuous-improvement-service-role --role-session-name "DockerBuildSession"); \
|
||||
export AWS_ACCESS_KEY_ID="$(echo $CREDS | jq -r '.Credentials.AccessKeyId')"; \
|
||||
export AWS_SECRET_ACCESS_KEY="$(echo $CREDS | jq -r '.Credentials.SecretAccessKey')"; \
|
||||
export AWS_SESSION_TOKEN="$(echo $CREDS | jq -r '.Credentials.SessionToken')"; \
|
||||
dotnet test "tests/${PROJECT}.Client.Test.Integration/${PROJECT}.Client.Test.Integration.csproj" \
|
||||
--configuration Release \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--verbosity=normal \
|
||||
--logger="trx;LogFileName=/test-results/integration-tests-client.trx" \
|
||||
-p:CollectCoverage=true \
|
||||
-p:CoverletOutputFormat=opencover \
|
||||
-p:CoverletOutput='/test-results/' \
|
||||
-p:MergeWith='/test-results/coverage.json' \
|
||||
-p:Exclude=\"[Strata.ContinuousImprovement.Client.Test.Integration]*,[Strata.ContinuousImprovement.JazzEntityFrameworkStub]*\"
|
||||
|
||||
# ###################
|
||||
# # DecisionSupport #
|
||||
# ###################
|
||||
|
||||
RUN dotnet test "tests/${DSPROJECT}.Biz.Test.Unit/${DSPROJECT}.Biz.Test.Unit.csproj" \
|
||||
--configuration Release \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--verbosity=normal \
|
||||
--logger="trx;LogFileName=/test-results/unit-tests-dsbiz.trx" \
|
||||
-p:CollectCoverage=true \
|
||||
-p:CoverletOutputFormat=opencover \
|
||||
-p:CoverletOutput='/test-results/' \
|
||||
-p:MergeWith='/test-results/coverage.json' \
|
||||
-p:Exclude=\"[Strata.ContinuousImprovement.Biz.Test.Unit]*,[Strata.ContinuousImprovement.JazzEntityFrameworkStub]*\"
|
||||
|
||||
RUN CREDS=$(aws sts assume-role --role-arn arn:aws:iam::809820578507:role/sdt-continuous-improvement-service-role --role-session-name "DockerBuildSession"); \
|
||||
export AWS_ACCESS_KEY_ID="$(echo $CREDS | jq -r '.Credentials.AccessKeyId')"; \
|
||||
export AWS_SECRET_ACCESS_KEY="$(echo $CREDS | jq -r '.Credentials.SecretAccessKey')"; \
|
||||
export AWS_SESSION_TOKEN="$(echo $CREDS | jq -r '.Credentials.SessionToken')"; \
|
||||
dotnet test "tests/${DSPROJECT}.Biz.Test.Integration/${DSPROJECT}.Biz.Test.Integration.csproj" \
|
||||
--configuration Release \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--verbosity=normal \
|
||||
--logger="trx;LogFileName=/test-results/integration-tests-dsbiz.trx" \
|
||||
-p:CollectCoverage=true \
|
||||
-p:CoverletOutputFormat=opencover \
|
||||
-p:CoverletOutput='/test-results/' \
|
||||
-p:MergeWith='/test-results/coverage.json' \
|
||||
-p:Exclude=\"[Strata.ContinuousImprovement.Biz.Test.Unit]*,[Strata.ContinuousImprovement.JazzEntityFrameworkStub]*\"
|
||||
|
||||
RUN mv /test-results/coverage.opencover.xml /test-results/cover.xml
|
||||
|
||||
# Publish project
|
||||
RUN dotnet publish "src/${PROJECT}.Api/${PROJECT}.Api.csproj" \
|
||||
--configuration Release \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--output /app
|
||||
|
||||
# Pack client project
|
||||
RUN dotnet pack "src/${PROJECT}.Client/${PROJECT}.Client.csproj" \
|
||||
--configuration Release \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--include-symbols \
|
||||
--include-source \
|
||||
--output /pack \
|
||||
-property:PackageVersion=${VERSION}
|
||||
|
||||
# Pack DS Biz project
|
||||
RUN dotnet pack "src/${DSPROJECT}.Biz/${DSPROJECT}.Biz.csproj" \
|
||||
--configuration Release \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--include-symbols \
|
||||
--include-source \
|
||||
--output /pack \
|
||||
-property:PackageVersion=${VERSION}
|
||||
|
||||
# Pack DS models project
|
||||
RUN dotnet pack "src/${DSPROJECT}.Models/${DSPROJECT}.Models.csproj" \
|
||||
--configuration Release \
|
||||
--no-restore \
|
||||
--no-build \
|
||||
--include-symbols \
|
||||
--include-source \
|
||||
--output /pack \
|
||||
-property:PackageVersion=${VERSION}
|
||||
|
||||
RUN if [ "${SONARLOGIN}" != "" ] ; then \
|
||||
/dc/dependency-check/bin/dependency-check.sh -f JSON -f HTML -s . -o ./buildlogs \
|
||||
--suppression ./sonarsuppressions.xml \
|
||||
--noupdate --nodeAuditSkipDevDependencies --disableNodeJS --disableRetireJS --ossIndexRemoteErrorWarnOnly true \
|
||||
--dbDriverName "com.microsoft.sqlserver.jdbc.SQLServerDriver" \
|
||||
--connectionString "jdbc:sqlserver://ddensqldevops01.sdt.local;Database=DependencyCheck;encrypt=true;trustServerCertificate=true;" \
|
||||
--dbUser "dcuser" --dbPassword "${SONARLOGIN}" && \
|
||||
dotnet sonarscanner end /d:sonar.login="${SONARLOGIN}"; \
|
||||
fi
|
||||
|
||||
RUN mkdir -p /src/buildlogs && touch /src/buildlogs/dependency-check-report.html
|
||||
|
||||
###############
|
||||
# Final image #
|
||||
###############
|
||||
FROM base AS final
|
||||
ARG PROJECT
|
||||
WORKDIR /app
|
||||
ARG PROJECT
|
||||
ENV PROJECTDLL=${PROJECT}.Api.dll
|
||||
ENV DOTNET_ENVIRONMENT=Development
|
||||
ENV ASPNETCORE_ENVIRONMENT=Development
|
||||
|
||||
COPY --from=build /app /app
|
||||
COPY --from=build /pack /pack
|
||||
COPY --from=build /test-results /test-results
|
||||
COPY --from=build /src/buildlogs/dependency-check-report.html /dc/dependency-check-report.html
|
||||
|
||||
ENTRYPOINT dotnet ${PROJECTDLL}
|
||||
Reference in New Issue
Block a user