Skip to content

Commit

Permalink
cloud build
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-garcia committed Mar 17, 2024
1 parent 203b2d9 commit 366e2e5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
ARG SENTRY_AUTH_TOKEN
ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
WORKDIR /src
COPY ["Sentaur.Leaderboard.Api/Sentaur.Leaderboard.Api.csproj", "Sentaur.Leaderboard.Api/"]
RUN dotnet restore "Sentaur.Leaderboard.Api/Sentaur.Leaderboard.Api.csproj"
Expand All @@ -15,6 +17,8 @@ RUN dotnet build "Sentaur.Leaderboard.Api.csproj" -c $BUILD_CONFIGURATION -o /ap

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
ARG SENTRY_AUTH_TOKEN
ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
RUN dotnet publish "Sentaur.Leaderboard.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
Expand Down
22 changes: 22 additions & 0 deletions Sentaur.Leaderboard.Api/Sentaur.Leaderboard.Api.http
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ Accept: application/json

###

GET https://sentaur-leaderboard-f7z2cjcdzq-uc.a.run.app/score/
Accept: application/json


###

DELETE https://sentaur-leaderboard-f7z2cjcdzq-uc.a.run.app/score?name=test&score=test
Accept: application/json


###

POST https://sentaur-leaderboard-f7z2cjcdzq-uc.a.run.app/token/
Content-Type: application/json

{
"username": "",
"password": ""
}


###

POST https://sentaur-leaderboard-f7z2cjcdzq-uc.a.run.app/score/
Content-Type: application/json
Expand Down
26 changes: 26 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
steps:
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: [
'-c',
'docker pull us.gcr.io/$PROJECT_ID/sentaur-leaderboard-api:latest || true',
]

- name: 'gcr.io/cloud-builders/docker'
args: [
'build',
'-t', 'us.gcr.io/$PROJECT_ID/sentaur-leaderboard-api:latest',
'-t', 'us.gcr.io/$PROJECT_ID/sentaur-leaderboard-api:$COMMIT_SHA',
'--cache-from', 'us.gcr.io/$PROJECT_ID/sentaur-leaderboard-api:latest',
'--build-arg', 'SENTRY_AUTH_TOKEN=$_SENTAUR_SURVIVOR_SENTRY_AUTH_TOKEN',
'--target', 'runtime',
'.'
]

# Only tag "latest" when on main
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: [
'-c',
'[[ "$BRANCH_NAME" == "main" ]] && docker push us.gcr.io/$PROJECT_ID/sentaur-leaderboard-api:latest || true',
]

0 comments on commit 366e2e5

Please sign in to comment.