Skip to content

Commit

Permalink
dotnet 8
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-tspencer committed Oct 8, 2024
1 parent d283116 commit 3fa24e1
Show file tree
Hide file tree
Showing 44 changed files with 358 additions and 415 deletions.
75 changes: 11 additions & 64 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,20 @@
name: Publish Docker Images
name: Build and Publish Image

on:
pull_request:
branches:
- development
push:
branches: [ development, staging ]
branches: [development, staging]
release:
types: [ "published" ]
workflow_dispatch:
inputs:
tagName:
description: 'Tag of the image you want to build and push'
required: true
types: ["published"]

jobs:
build:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2

- name: Prepare
id: prep
run: |
DOCKER_IMAGE=cmusei/steamfitter-api
VERSION=development
if [[ ! -z "${{ github.event.inputs.tagName }}" ]]; then
VERSION=${{ github.event.inputs.tagName }}
TAGS="${DOCKER_IMAGE}:${VERSION}"
elif [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
MAJORMINORVERSION=$(echo $VERSION | grep -oP '(\d+)\.(\d+)')
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${MAJORMINORVERSION}"
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
TAGS="${DOCKER_IMAGE}:${VERSION}"
fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo ::set-output name=push::false
echo "event is pull_request, not pushing image"
else
echo ::set-output name=push::true
echo "event is not pull_request, pushing image"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: ${{ steps.prep.outputs.push }}
pull: true
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
build-and-publish:
name: Build and Publish
uses: cmu-sei/Crucible-Github-Actions/.github/workflows/[email protected]
with:
imageName: cmusei/steamfitter-api
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
22 changes: 10 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
#
#multi-stage target: dev
#
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS dev
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS dev

ENV ASPNETCORE_URLS=http://0.0.0.0:4302 \
ASPNETCORE_ENVIRONMENT=DEVELOPMENT
ENV ASPNETCORE_HTTP_PORTS=4300
ENV ASPNETCORE_ENVIRONMENT=DEVELOPMENT

# Must be copied above both steamfitter and stackstorm. Will not accept ../stackstorm.api for copying.
COPY . /app
WORKDIR /app/Steamfitter.Api

WORKDIR /app
RUN dotnet publish -c Release -o /app/dist

CMD ["dotnet", "run"]

#
#multi-stage target: prod
#
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS prod
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS prod
ARG commit
ENV COMMIT=$commit
ENV DOTNET_HOSTBUILDER__RELOADCONFIGCHANGE=false
COPY --from=dev /app/dist /app

WORKDIR /app
ENV ASPNETCORE_URLS=http://*:80
ENV ASPNETCORE_HTTP_PORTS=80
EXPOSE 80
CMD [ "dotnet", "Steamfitter.Api.dll" ]

RUN apt-get update && \
apt-get install -y jq
CMD ["dotnet", "Steamfitter.Api.dll"]
7 changes: 3 additions & 4 deletions Steamfitter.Api.Data/Extensions/ModelBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void ApplyConfigurations(this ModelBuilder builder)
/// If using PostgreSQL, add uuid generation extension and set all Guid Identity properties to use it
/// Without this, the client has to provide the UUID, which doesn't matter too much for EF, but can be annoying when making manual changes to the db.
/// </summary>
/// <param name="builder">The ModelBuilder</param>
/// <param name="builder">The ModelBuilder</param>
public static void AddPostgresUUIDGeneration(this ModelBuilder builder)
{
builder.HasPostgresExtension("uuid-ossp");
Expand All @@ -45,8 +45,8 @@ public static void AddPostgresUUIDGeneration(this ModelBuilder builder)
.GetEntityTypes()
.SelectMany(t => t.GetProperties())
.Where(p => p.ClrType == typeof(Guid))
.Select(p => builder.Entity(p.DeclaringEntityType.ClrType).Property(p.Name))
.Where(p => p.Metadata.ValueGenerated == Microsoft.EntityFrameworkCore.Metadata.ValueGenerated.OnAdd &&
.Select(p => builder.Entity(p.DeclaringType.ClrType).Property(p.Name))
.Where(p => p.Metadata.ValueGenerated == ValueGenerated.OnAdd &&
p.Metadata.IsPrimaryKey())
)
{
Expand Down Expand Up @@ -80,4 +80,3 @@ public static void UsePostgresCasing(this ModelBuilder builder)
}
}
}

7 changes: 2 additions & 5 deletions Steamfitter.Api.Data/Steamfitter.Api.Data.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<ProjectGuid>{0C65D9CC-A91F-46D5-BC1A-19A658064836}</ProjectGuid>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
</ItemGroup>

</Project>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Steamfitter.Api.Migrations.PostgreSQL.Migrations
{
public partial class initial : Migration
public partial class Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down Expand Up @@ -235,4 +235,3 @@ protected override void Down(MigrationBuilder migrationBuilder)
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,3 @@ protected override void Down(MigrationBuilder migrationBuilder)
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,3 @@ protected override void Down(MigrationBuilder migrationBuilder)
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Steamfitter.Api.Migrations.PostgreSQL.Migrations
{
public partial class cascadeDeletes : Migration
public partial class CascadeDeletes : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Steamfitter.Api.Migrations.PostgreSQL.Migrations
{
public partial class hashSets : Migration
public partial class HashSets : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Steamfitter.Api.Migrations.PostgreSQL.Migrations
{
public partial class renameNouns : Migration
public partial class RenameNouns : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Steamfitter.Api.Migrations.PostgreSQL.Migrations
{
public partial class renameIndexes : Migration
public partial class RenameIndexes : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Steamfitter.Api.Migrations.PostgreSQL.Migrations
{
public partial class taskIterations : Migration
public partial class TaskIterations : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Steamfitter.Api.Migrations.PostgreSQL.Migrations
{
public partial class resultAction : Migration
public partial class ResultAction : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Steamfitter.Api.Migrations.PostgreSQL.Migrations
{
public partial class nullTaskId : Migration
public partial class NullTaskId : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Steamfitter.Api.Migrations.PostgreSQL.Migrations
{
public partial class nullScenarioTemplateId : Migration
public partial class NullScenarioTemplateId : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Steamfitter.Api.Migrations.PostgreSQL.Migrations
{
public partial class vmcreds : Migration
public partial class Vmcreds : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Steamfitter.Api.Migrations.PostgreSQL.Migrations
{
public partial class vmcreds2 : Migration
public partial class Vmcreds2 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
Expand Down
Loading

0 comments on commit 3fa24e1

Please sign in to comment.