Skip to content

Commit

Permalink
Merge pull request #1 from argon-chat/12-auto-deploy-to-stage
Browse files Browse the repository at this point in the history
12 auto deploy to stage
  • Loading branch information
0xF6 authored Oct 14, 2024
2 parents 06f2b3b + 7886ca6 commit 0cafb94
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 32 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
41 changes: 41 additions & 0 deletions .github/workflows/api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: .NET

on:
push:
branches: [ "master" ]
paths:
- 'src/Argon.Api/**'
pull_request:
branches: [ "master" ]
paths:
- 'src/Argon.Api/**'

jobs:
qa:
runs-on: ARM64
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
build:
# if: github.ref == 'refs/heads/master'
runs-on: ARM64
needs: qa
steps:
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v1
with:
registry: ${{ secrets.REGISTRY }}
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PWD }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./src/Argon.Api/Dockerfile
push: true
tags: reg.staging.svck.dev/argon/api-orleans:${{ github.run_number }}
# platforms: linux/arm64/v8

28 changes: 0 additions & 28 deletions .github/workflows/dotnet.yml

This file was deleted.

7 changes: 7 additions & 0 deletions src/Argon.Api/Argon.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
Expand All @@ -23,4 +24,10 @@
<ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj"/>
</ItemGroup>

<ItemGroup>
<Content Include="..\..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions src/Argon.Api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine-arm64v8 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-arm64v8 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"]
COPY ["src/ServiceDefaults/ServiceDefaults.csproj", "src/ServiceDefaults/"]
RUN dotnet restore "src/Argon.Api/Argon.Api.csproj"
COPY . .
WORKDIR "/src/src/Argon.Api"
RUN dotnet build "Argon.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build

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

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Argon.Api.dll"]
7 changes: 4 additions & 3 deletions src/Argon.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ public static async Task Main(string[] args)
siloBuilder.AddMemoryGrainStorage("replaceme"); // TODO: replace me pls
});
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
using var scope = app.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
Thread.Sleep(5000);
await db.Database.MigrateAsync();
}

app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.MapDefaultEndpoints();
var buildTime = File.GetLastWriteTimeUtc(typeof(Program).Assembly.Location);
app.MapGet("/", () => new { buildTime = buildTime });
await app.RunAsync();
}
}
2 changes: 1 addition & 1 deletion src/Argon.Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ConnectionStrings": {
"DefaultConnection": "Host=database;Port=5432;Username=svck;Password=Password123;Database=apiDb",
"DefaultConnection": "Host=localhost;Port=5432;Username=svck;Password=1ed1f86a265ecffa4c0de1a1;Database=argon_api",
"cache": "localhost:1500",
"rmq": "amqp://svck:Password123@localhost:5672"
},
Expand Down

0 comments on commit 0cafb94

Please sign in to comment.