Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
**/charts
**/docker-compose*
**/Dockerfile*
**/*.Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
Expand All @@ -27,4 +28,7 @@ README.md
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
!.git/refs/heads/**
**/*.local
**/*.swp
.secrets
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
packages: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .NET Core
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
uses: docker/build-push-action@v5.1.0
with:
context: .
file: ./docker/Prod.Dockerfile
file: ./src/Kattbot/prod.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
16 changes: 7 additions & 9 deletions .github/workflows/release-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ env:
REGISTRY: ghcr.io
IMAGE_NAME: kattbot
COMPOSE_PROJECT_NAME: kattbot
COMPOSE_FILE_NAME: prod-compose.yml
COMPOSE_FILE_PATH_SRC: docker/docker-compose.prod.yml
COMPOSE_FILE_NAME: docker-compose.prod.yml
DB_NAME: kattbot
DB_BACKUP_SCRIPT: kattbot-backup-db.sh
DB_MIGRATION_SCRIPT: database_migration.sql
Expand Down Expand Up @@ -61,7 +62,7 @@ jobs:
username: ${{secrets.KATTBOT_USER}}
key: ${{secrets.KATTBOT_KEY}}
passphrase: ${{secrets.KATTBOT_PASSPHRASE}}
source: "docker/${{ env.COMPOSE_FILE_NAME }}"
source: ${{ env.COMPOSE_FILE_PATH_SRC }}
target: "$HOME/"
strip_components: 1
overwrite: true
Expand All @@ -84,13 +85,10 @@ jobs:
script_stop: true
script: |
FULL_IMAGE_NAME="$REGISTRY/$REPOSITORY_NAME/$IMAGE_NAME:$IMAGE_TAG"
FULL_IMAGE_NAME_PREVIOUS="$REGISTRY/$REPOSITORY_NAME/$IMAGE_NAME:$IMAGE_TAG-previous"
echo "Full image name: $FULL_IMAGE_NAME"

MIGRATIONS_CONTAINER_NAME="$COMPOSE_PROJECT_NAME-migrations"

# Tag the previous image with the previous tag, if it exists
docker image tag $FULL_IMAGE_NAME $FULL_IMAGE_NAME_PREVIOUS || true

# Pull the image from the registry
echo $GHCR_PASSWORD | docker login $REGISTRY -u $GHCR_USERNAME --password-stdin
docker pull $FULL_IMAGE_NAME
Expand All @@ -116,6 +114,9 @@ jobs:
# Run the database migration script
psql -d $DB_NAME -q -f "$TMP_MIGRATIONS_DIR/$DB_MIGRATION_SCRIPT"

# Remove the temporary directory
rm -rf $TMP_MIGRATIONS_DIR

# Take down the old compose project, if it exists
docker compose -p $COMPOSE_PROJECT_NAME down || true

Expand All @@ -124,9 +125,6 @@ jobs:

# Prune untagged images
docker image prune -f

# Remove the temporary directory
rm -rf $TMP_MIGRATIONS_DIR
envs: >-
HOST_GATEWAY_IP,
REGISTRY,
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,6 @@ ASALocalRun/
# BeatPulse healthcheck temp database
healthchecksdb

Kattbot.Data.Migrations/database_migration.sql

.env.local
*.local
*.swp
.secrets
58 changes: 13 additions & 45 deletions Kattbot.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,21 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kattbot", "Kattbot\Kattbot.csproj", "{9EB340B8-8D7D-4BBA-A146-33F7A15B13CE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kattbot", "src\Kattbot\Kattbot.csproj", "{9EB340B8-8D7D-4BBA-A146-33F7A15B13CE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kattbot.Tests", "Kattbot.Tests\Kattbot.Tests.csproj", "{1C2153F7-4660-4021-9864-8F1F704054BF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kattbot.Tests", "tests\Kattbot.Tests\Kattbot.Tests.csproj", "{1C2153F7-4660-4021-9864-8F1F704054BF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2D6F1BD9-5D5D-4C85-B254-B773679A5AF9}"
ProjectSection(SolutionItems) = preProject
.dockerignore = .dockerignore
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
Dotnet_cheatsheet.md = Dotnet_cheatsheet.md
Readme.md = Readme.md
EndProjectSection
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kattbot.Data", "src\Kattbot.Data\Kattbot.Data.csproj", "{F454BCE5-C964-4720-AD84-96A07FA7B8B1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kattbot.Data", "Kattbot.Data\Kattbot.Data.csproj", "{F454BCE5-C964-4720-AD84-96A07FA7B8B1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kattbot.Common", "src\Kattbot.Common\Kattbot.Common.csproj", "{FFC07C89-ECA8-4887-9376-DA43C5FC83AB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kattbot.Common", "Kattbot.Common\Kattbot.Common.csproj", "{FFC07C89-ECA8-4887-9376-DA43C5FC83AB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kattbot.Data.Migrations", "src\Kattbot.Data.Migrations\Kattbot.Data.Migrations.csproj", "{D26776E6-F360-425C-9281-F4E7B176197E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kattbot.Data.Migrations", "Kattbot.Data.Migrations\Kattbot.Data.Migrations.csproj", "{D26776E6-F360-425C-9281-F4E7B176197E}"
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker", "docker\docker.dcproj", "{642D827F-5BA9-4177-AE3D-4BAEE013BC3F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{727EE4ED-CFEC-4BBC-B67A-3DA7F8EE3F1E}"
ProjectSection(SolutionItems) = preProject
scripts\kattbot-backup-db.sh = scripts\kattbot-backup-db.sh
EndProjectSection
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E845ABD6-198E-45CF-92D5-97F1A5E741A3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{524F91BA-735B-4F73-BEDD-A3CC1DEB452C}"
ProjectSection(SolutionItems) = preProject
.config\dotnet-tools.json = .config\dotnet-tools.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{DC675219-AB3D-40B1-BA7C-27C5613023BC}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build.yml = .github\workflows\build.yml
.github\dependabot.yml = .github\dependabot.yml
.github\workflows\release-v2.yml = .github\workflows\release-v2.yml
.github\workflows\restart-v2.yml = .github\workflows\restart-v2.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{26E4A78E-3DA9-4825-896B-4A9B0B017188}"
ProjectSection(SolutionItems) = preProject
docker\docker-compose.yml = docker\docker-compose.yml
docker\Dockerfile = docker\Dockerfile
docker\prod-compose.yml = docker\prod-compose.yml
docker\Prod.Dockerfile = docker\Prod.Dockerfile
EndProjectSection
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-vs", "docker-vs\docker-vs.dcproj", "{642D827F-5BA9-4177-AE3D-4BAEE013BC3F}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{17BE3AFF-E650-40BC-A5EF-DF77B794D988}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -100,10 +67,11 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{727EE4ED-CFEC-4BBC-B67A-3DA7F8EE3F1E} = {2D6F1BD9-5D5D-4C85-B254-B773679A5AF9}
{524F91BA-735B-4F73-BEDD-A3CC1DEB452C} = {2D6F1BD9-5D5D-4C85-B254-B773679A5AF9}
{DC675219-AB3D-40B1-BA7C-27C5613023BC} = {2D6F1BD9-5D5D-4C85-B254-B773679A5AF9}
{26E4A78E-3DA9-4825-896B-4A9B0B017188} = {2D6F1BD9-5D5D-4C85-B254-B773679A5AF9}
{9EB340B8-8D7D-4BBA-A146-33F7A15B13CE} = {E845ABD6-198E-45CF-92D5-97F1A5E741A3}
{FFC07C89-ECA8-4887-9376-DA43C5FC83AB} = {E845ABD6-198E-45CF-92D5-97F1A5E741A3}
{F454BCE5-C964-4720-AD84-96A07FA7B8B1} = {E845ABD6-198E-45CF-92D5-97F1A5E741A3}
{D26776E6-F360-425C-9281-F4E7B176197E} = {E845ABD6-198E-45CF-92D5-97F1A5E741A3}
{1C2153F7-4660-4021-9864-8F1F704054BF} = {17BE3AFF-E650-40BC-A5EF-DF77B794D988}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {49047B12-10BC-4E9D-9DA6-758947DF9CE8}
Expand Down
1 change: 0 additions & 1 deletion Kattbot/Dockerfile

This file was deleted.

8 changes: 0 additions & 8 deletions docker-vs/docker-compose.override.yml

This file was deleted.

36 changes: 0 additions & 36 deletions docker-vs/docker-compose.yml

This file was deleted.

15 changes: 0 additions & 15 deletions docker-vs/docker-vs.dcproj

This file was deleted.

13 changes: 0 additions & 13 deletions docker/Dockerfile

This file was deleted.

32 changes: 0 additions & 32 deletions docker/Prod.Dockerfile

This file was deleted.

8 changes: 4 additions & 4 deletions docker/prod-compose.yml → docker/docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.4'
name: kattbot

services:
kattbot:
Expand All @@ -8,6 +8,6 @@ services:
extra_hosts:
- "host.docker.internal=$HOST_GATEWAY_IP"
environment:
Kattbot__BotToken: $BOT_TOKEN
Kattbot__OpenAiApiKey: $OPENAI_API_KEY
Kattbot__ConnectionString: $DB_CONNECTION_STRING
Kattbot__BotToken: $BOT_TOKEN
Kattbot__OpenAiApiKey: $OPENAI_API_KEY
Kattbot__ConnectionString: $DB_CONNECTION_STRING
12 changes: 7 additions & 5 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
version: '3.4'
name: kattbot-dev

services:
kattbot:
build:
context: ..
dockerfile: docker/Dockerfile
depends_on:
- kattbot-pgsql
dockerfile: src/Kattbot/Dockerfile
environment:
- DOTNET_ENVIRONMENT=Development
env_file:
- path: .env.local
required: false

volumes:
- ${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro

kattbot-pgsql:
image: postgres:15.5
ports:
- "5433:5432"
profiles:
- database
environment:
POSTGRES_USER: kattbot
POSTGRES_PASSWORD: hunter2
Expand Down
15 changes: 15 additions & 0 deletions docker/docker.dcproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<DockerPublishLocally>False</DockerPublishLocally>
<ProjectGuid>642d827f-5ba9-4177-ae3d-4baee013bc3f</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.yml" />
</ItemGroup>
<ItemGroup>
<Content Include="docker-compose.prod.yml" />
</ItemGroup>
</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions src/Kattbot/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Debug
WORKDIR /src
COPY ["Directory.Build.props", "."]
COPY ["src/Kattbot/Kattbot.csproj", "Kattbot/"]
COPY ["src/Kattbot.Common/Kattbot.Common.csproj", "Kattbot.Common/"]
COPY ["src/Kattbot.Data/Kattbot.Data.csproj", "Kattbot.Data/"]
RUN dotnet restore "./Kattbot/Kattbot.csproj"
COPY ["Kattbot.sln", "."]
COPY ["stylecop.json", "."]
COPY [".editorconfig", "."]
COPY src .
RUN dotnet build "./Kattbot/Kattbot.csproj" -c $BUILD_CONFIGURATION --no-restore
USER $APP_UID
ENTRYPOINT ["dotnet", "run", "--project", "Kattbot/Kattbot.csproj", "--no-build"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading