-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
46 lines (37 loc) · 1.13 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app
# Install SonarScanner
ENV PATH="${PATH}:/root/.dotnet/tools"
RUN apt-get update -qq && apt-get install -qq -y default-jre
RUN dotnet tool install --global dotnet-sonarscanner --version 4.5.0
ARG PR_BASE
ARG PR_BRANCH
ARG PR_ID
ARG SONAR_HOST=https://sonarcloud.io
ARG SONAR_ORG=ceruleanlabs
ARG SONAR_PROJECT=ceruleanlabs_smashbot
ARG SONAR_TOKEN
COPY . ./
# Restore packages as separate layer
RUN dotnet restore
# Start code analysis
RUN dotnet-sonarscanner begin \
/k:${SONAR_PROJECT} \
/d:sonar.host.url=${SONAR_HOST} \
/d:sonar.login=${SONAR_TOKEN} \
/d:sonar.organization=${SONAR_ORG} \
/d:sonar.pullrequest.branch=${PR_BRANCH} \
/d:sonar.pullrequest.base=${PR_BASE} \
/d:sonar.pullrequest.key=${PR_ID}
# Run tests
RUN dotnet test
# Build
RUN dotnet publish src/SmashBot.csproj -c Release -o out
# Finish code analysis
RUN dotnet-sonarscanner end \
/d:sonar.login=${SONAR_TOKEN}
# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/src/out .
ENTRYPOINT ["dotnet", "SmashBot.dll"]