Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new host to be used for container #1997

Merged
merged 32 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2acef87
Don't include empty stub file
bording Jul 24, 2024
8bc4fbc
Don't assume Frontend build outDir is ServicePulse.Host
bording Jul 24, 2024
9468792
Add project for container host
bording Jul 24, 2024
b193e7f
Add packages
bording Jul 24, 2024
8c03ae5
Serve embedded Frontend output
bording Jul 24, 2024
3efd6a7
Serve dynamic app.constants.js instead of embedded file
bording Jul 24, 2024
fcce3fb
Customize constants via environment variables
bording Jul 24, 2024
2199a61
Add reverse proxy for API access
bording Jul 24, 2024
d6bf5d2
Handle legacy MONITORING_URLS value
bording Jul 25, 2024
88feccb
Change Yarp log level
bording Jul 25, 2024
d4e8f69
Improve host build scripts
bording Jul 26, 2024
4fa05e8
Formatting
bording Jul 26, 2024
cdd4635
Add new Dockerfile and remove old one
bording Jul 25, 2024
525f145
Remove unneeded dockerignore
bording Jul 26, 2024
424d81a
Update PlatformSample to use new host
bording Jul 26, 2024
1422397
Update ServicePulse.Host.Tests to react to changes
bording Jul 26, 2024
021b4eb
Use chiseled image
bording Jul 26, 2024
62ae770
Update container README
bording Jul 26, 2024
a736599
Update workflows
bording Jul 26, 2024
ff1cb93
Change container workdir to /app so config is loaded
bording Jul 29, 2024
c26dbf6
Suppress DataProtection warnings since it's not being used
bording Jul 29, 2024
a7ec1c2
Change default port to 9090
bording Aug 6, 2024
5ccd356
Split logic into separate files
bording Aug 6, 2024
5411363
Build Frontend inside container
bording Aug 6, 2024
5659abd
Stop deleting file that doesn't need to be removed
bording Aug 6, 2024
ee254ca
Read MinVer settings from Custom.Build.props
bording Aug 6, 2024
bb03467
Use BUILDPLATFORM for Frontend build image
bording Aug 6, 2024
224f86f
Don't build arm32 since there is no chiseled image for it
bording Aug 6, 2024
e78300b
Remove unneeded step in workflow
bording Aug 6, 2024
c83dcb5
Suppress packing warning
bording Aug 6, 2024
6f62e2a
Update container README
bording Aug 7, 2024
eafad10
Update container info in README
bording Aug 9, 2024
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
2 changes: 0 additions & 2 deletions .dockerignore

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4.0.3
with:
node-version: 21.6.x
node-version: 21.6.x
- name: Build Frontend
run: .\build.ps1
working-directory: src/ServicePulse.Host
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Build
run: dotnet build src --configuration Release
- name: Run .NET tests
uses: Particular/run-tests-action@v1.7.0
uses: Particular/run-tests-action@v1.7.0
# Upload assets and packages
- name: Upload assets
uses: actions/upload-artifact@v4.3.6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-container-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: particular/servicepulse
readme-filepath: ./src/Container/README.md
readme-filepath: ./Container-README.md
42 changes: 17 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,43 +121,35 @@ jobs:
- name: Install MinVer CLI
run: dotnet tool install --global minver-cli
- name: Determine version
run: echo "MinVerVersion=$(minver)" >> $GITHUB_ENV
shell: pwsh
run: |
# Read settings from Custom.Build.props
[xml]$xml = Get-Content ./src/Custom.Build.props
$minMajorMinor = $xml.selectNodes('/Project/PropertyGroup/MinVerMinimumMajorMinor').InnerText
$autoIncrement = $xml.selectNodes('/Project/PropertyGroup/MinVerAutoIncrement').InnerText
echo "MinVerMinimumMajorMinor=$minMajorMinor, MinVerAutoIncrement=$autoIncrement"
if (-not ($minMajorMinor -and $autoIncrement)) {
throw "Missing MinVer settings in Custom.Build.props"
}

# Execute MinVer
echo "MinVerVersion=$(minver --minimum-major-minor $minMajorMinor --auto-increment $autoIncrement)" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Validate build version
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
uses: ./.github/actions/validate-version
with:
version: ${{ env.MinVerVersion }}
- name: Set up Node.js
uses: actions/setup-node@v4.0.3
with:
node-version: 21.6.x
- name: Build Frontend
run: .\build.ps1
working-directory: src/ServicePulse.Host
shell: pwsh
- name: Update app.constants.js with MinVerVersion
run: |
$filename = "src/ServicePulse.Host/app/js/app.constants.js"
(Get-Content $filename).replace("1.2.0", "${{ env.MinVerVersion }}") | Set-Content $filename
shell: pwsh
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.6.1
- name: Pull nginx:stable-alpine and determine digest
run: |
docker pull nginx:stable-alpine
echo "NGINX_DIGEST=$(docker inspect -f json nginx:stable-alpine | jq -r .[0].RepoDigests[0] | cut -d@ -f2)" >> $GITHUB_ENV
- name: Log in to GitHub container registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build & inspect image
env:
TAG_NAME: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || env.MinVerVersion }}
run: |
docker buildx build --push --tag ghcr.io/particular/servicepulse:${{ env.TAG_NAME }} \
--file src/Container/Dockerfile \
--build-arg NGINX_TAGORDIGEST="@${{ env.NGINX_DIGEST }}" \
--file src/ServicePulse/Dockerfile \
--build-arg VERSION=${{ env.MinVerVersion }} \
--build-arg GITHUB_SHA=${{ github.sha }} \
--build-arg GITHUB_REF_NAME=${{ github.ref.name }} \
--annotation "index:org.opencontainers.image.title=ServicePulse" \
--annotation "index:org.opencontainers.image.description=ServicePulse provides real-time production monitoring for distributed applications. It monitors the health of a system's endpoints, detects processing errors, sends failed messages for reprocessing, and ensures the specific environment's needs are met, all in one consolidated dashboard." \
--annotation "index:org.opencontainers.image.created=$(date '+%FT%TZ')" \
Expand All @@ -168,6 +160,6 @@ jobs:
--annotation "index:org.opencontainers.image.source=https://github.com/${{ github.repository }}/tree/${{ github.sha }}" \
--annotation "index:org.opencontainers.image.url=https://hub.docker.com/r/particular/servicepulse" \
--annotation "index:org.opencontainers.image.documentation=https://docs.particular.net/servicepulse/" \
--annotation "index:org.opencontainers.image.base.name=nginx@${{ env.NGINX_DIGEST }}" \
--platform linux/arm64,linux/arm,linux/amd64 .
docker buildx imagetools inspect ghcr.io/particular/servicepulse:${{ env.TAG_NAME }}
--annotation "index:org.opencontainers.image.base.name=mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled-composite" \
--platform linux/arm64,linux/amd64 .
docker buildx imagetools inspect ghcr.io/particular/servicepulse:${{ env.TAG_NAME }}
20 changes: 10 additions & 10 deletions src/Container/README.md → Container-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ This document describes basic usage and information related to the ServicePulse
The following is the most basic way to create a ServicePulse container using [Docker](https://www.docker.com/):

```shell
docker run -p 9090:90 particular/servicepulse:latest
docker run -p 9090:9090 particular/servicepulse:latest
```

### Environment Variables

- **`SERVICECONTROL_URL`**: _Default_: `http://localhost:33333/api/`. The url to your ServiceControl instance
- **`MONITORING_URLS`**: _Default_: `['http://localhost:33633/']`. A JSON array of URLs to your monitoring instances
- **`SERVICECONTROL_URL`**: _Default_: `http://localhost:33333`. The url to your ServiceControl instance
- **`MONITORING_URL`**: _Default_: `http://localhost:33633`. The url to your monitoring instance
- **`DEFAULT_ROUTE`**: _Default_: `/dashboard`. The default page that should be displayed when visiting the site
- **`SHOW_PENDING_RETRY`** _Default_: `false`. Set to `true` to show details of pending retries

It may be desireable to run the ServiceControl services in an isolated network. When doing so ServicePulse must be configured to connect to those services using environment variables:
It may be desireable to run the ServiceControl services in an isolated network. When doing so, ServicePulse must be configured to connect to those services using environment variables:

```shell
docker run -p 9090:90 -e SERVICECONTROL_URL="http://servicecontrol:33333/api/" -e MONITORING_URLS="['http://servicecontrol-monitoring:33633']" particular/servicepulse:latest
docker run -p 9090:9090 -e SERVICECONTROL_URL="http://servicecontrol:33333" -e MONITORING_URL="http://servicecontrol-monitoring:33633" particular/servicepulse:latest
```

Or as part of a [Docker Compose services specification](https://docs.docker.com/compose/compose-file/05-services/):
Expand All @@ -29,10 +29,10 @@ Or as part of a [Docker Compose services specification](https://docs.docker.com/
services:
servicepulse:
ports:
- 9090:90
- 9090:9090
environment:
- SERVICECONTROL_URL=http://servicecontrol:33333/api/
- MONITORING_URLS=['http://servicecontrol-monitoring:33633']
- SERVICECONTROL_URL=http://servicecontrol:33333
- MONITORING_URL=http://servicecontrol-monitoring:33633
image: particular/servicepulse:latest
```

Expand Down Expand Up @@ -68,9 +68,9 @@ The major version tag is never added to images pushed to [the GitHub Container R

The latest release within a minor version will be tagged with `{major}.{minor}` on images pushed to Docker Hub. This allows users to target the latest patch within a specific minor version.

## Built With
## Image architecture

This image is built from the stable Alpine version of the [nginx official Docker image](https://hub.docker.com/_/nginx/).
This image is a multi-arch image based on the `mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled-composite` base image supporting `linux/arm64` and `linux/amd64`.

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ ServicePulse is supported on the following desktop browser versions:

## Container image development

A Dockerfile for ServicePulse resides within the [`src/Container`](https://github.com/Particular/ServicePulse/tree/master/src/Container) folder. The container images are all built as part of the [release workflow](https://github.com/Particular/ServicePulse/blob/master/.github/workflows/release.yml) and staged in the [Github Container Registry](https://github.com/Particular/ServicePulse/pkgs/container/servicepulse). For branches with PRs the image will be tagged with the pr number, e.g. `pr-1234`.
A Dockerfile for ServicePulse resides within the [`src/ServicePulse`](https://github.com/Particular/ServicePulse/tree/master/src/ServicePulse) folder. The container images are all built as part of the [release workflow](https://github.com/Particular/ServicePulse/blob/master/.github/workflows/release.yml) and staged in the [Github Container Registry](https://github.com/Particular/ServicePulse/pkgs/container/servicepulse). For branches with PRs, the image will be tagged with the PR number, e.g. `pr-1234`.
7 changes: 2 additions & 5 deletions src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ src/scaffolding.config
ServicePulse.Host.Tests/node_modules
package-lock.json

# bower artifacts
ServicePulse.Host/app/bower_components

# Chutzpah folders
_Chutzpah.*/

# Webpack results
ServicePulse.Host/angular/app/modules/dist
# ServicePulse.Host app
ServicePulse.Host/app
36 changes: 0 additions & 36 deletions src/Container/Dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions src/Container/app.constants.template

This file was deleted.

18 changes: 0 additions & 18 deletions src/Container/nginx.conf

This file was deleted.

6 changes: 0 additions & 6 deletions src/Container/updateconstants.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/Custom.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
<PropertyGroup Label="Treat as warnings the transitive dependencies problems">
<NuGetAuditMode>all</NuGetAuditMode>
</PropertyGroup>

</Project>
1 change: 0 additions & 1 deletion src/Frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export default defineConfig({
},
base: "./",
build: {
outDir: "../ServicePulse.Host/app",
emptyOutDir: true,
sourcemap: true,
rollupOptions: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<Description>Particular ServicePulse binaries for use by Particular.PlatformSample. Not intended for use outside of Particular.PlatformSample.</Description>
bording marked this conversation as resolved.
Show resolved Hide resolved
<PackageProjectUrl>https://docs.particular.net/servicepulse/</PackageProjectUrl>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);AddFilesToPackage</TargetsForTfmSpecificContentInPackage>
<NoWarn>$(NoWarn);NU5100</NoWarn>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ServicePulse.Host\ServicePulse.Host.csproj" PrivateAssets="All" />
<ProjectReference Include="..\ServicePulse\ServicePulse.csproj" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Particular.Packaging" Version="4.1.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<Content Include="..\ServicePulse.Host\app\**\*" PackagePath="platform\servicepulse" Visible="false" Link="hidden" />
</ItemGroup>

<ItemGroup>
<None Remove="buildProps\**\*" />
<Content Include="buildProps\**\*" PackagePath="" />
</ItemGroup>

<Target Name="AddFilesToPackage">
<ItemGroup>
<TfmSpecificPackageFile Include="..\ServicePulse\bin\$(Configuration)\$(TargetFramework)\**\*" PackagePath="platform\servicepulse" />
</ItemGroup>
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildAssemblyVersion)' == '' Or '$(MSBuildAssemblyVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<Project>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\..\platform\servicepulse\**\*" CopyToOutputDirectory="PreserveNewest" Link="platform\servicepulse\%(RecursiveDir)%(Filename)%(Extension)" />
<None Include="$(MSBuildThisFileDirectory)\..\platform\servicepulse\**\*" CopyToOutputDirectory="PreserveNewest" LinkBase="platform\servicepulse" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildAssemblyVersion)' == '' Or '$(MSBuildAssemblyVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<Project>

<Import Project="../build/Particular.PlatformSample.ServicePulse.props" />

Expand Down
13 changes: 0 additions & 13 deletions src/ServicePulse.Host.Tests/Api/APIApprovals.cs

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion src/ServicePulse.Host.Tests/Owin/StaticMiddlewareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public async Task Should_find_prefer_constants_file_on_disk_over_embedded_if_bot
}
};
await middleware.Invoke(context);
const long sizeOfFileOnDisk = 232; // this is the /app/js/app.constants.js file
const long sizeOfFileOnDisk = 215; // this is the /app/js/app.constants.js file
Assert.That(context.Response.ContentLength, Is.EqualTo(sizeOfFileOnDisk));
Assert.That(context.Response.ContentType, Is.EqualTo("application/javascript"));
}
Expand Down
20 changes: 4 additions & 16 deletions src/ServicePulse.Host.Tests/ServicePulse.Host.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
Expand All @@ -9,10 +9,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
Expand All @@ -21,17 +18,8 @@
</ItemGroup>

<ItemGroup>
<Content Include="..\Frontend\public\js\app.constants.js" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<None Update="app\filename.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="app\js\app.constants.js">
<LogicalName>%(RelativeDir)%(Filename)%(Extension)</LogicalName>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="..\Frontend\public\js\app.constants.js" CopyToOutputDirectory="PreserveNewest" LinkBase="app/js" />
<None Update="app\filename.js" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
Loading