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
50 changes: 50 additions & 0 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

# https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images

name: Publish Test Docker Image

on:
pull_request:

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: carlpaton/redis-administrator:test

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: index.docker.io/carlpaton/redis-administrator
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

# https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images

name: Publish Docker image
name: Publish Latest Docker Image

on:
workflow_dispatch:
push:
branches:
- 'master'
Expand Down Expand Up @@ -43,7 +42,7 @@ jobs:
context: .
file: ./Dockerfile
push: true
tags: carlpaton/redis-administrator:develop
tags: carlpaton/redis-administrator:latest

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
Expand Down
2 changes: 1 addition & 1 deletion Common/Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use the SDK image for the build stage
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-env
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app

# Copy csproj files and restore as distinct layers
Expand All @@ -19,7 +19,7 @@ RUN dotnet publish ./WebApp/WebApp.csproj -c Release -o out
# RUN dotnet test "./IntegrationTests/IntegrationTests.csproj" -c Release --no-build --no-restore

# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
# Copy the published output from the build-env stage
COPY --from=build-env /app/out ./
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/IntegrationTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ docker run --name red-admin -d -p 8081:80 --env REDIS_CONNECTION=red-srv,allowAd
Pull requests welcome!

- [Local Setup](./docs/local-setup.md)
- [Redis Types](https://carlpaton.github.io/2022/02/redis-types/)

## Developers

Expand Down
2 changes: 1 addition & 1 deletion RedisRepository/RedisRepository.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion WebApp/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
&copy; @DateTime.Now.ToString("yyyy") - <a asp-area="" asp-controller="Home" asp-action="Privacy">Redis Administrator</a>
is powered by <a href="https://getbootstrap.com/docs/4.0/getting-started/introduction/" target="_blank">Bootstrap</a>
, <a href="https://github.com/StackExchange/StackExchange.Redis/" target="_blank">StackExchange.Redis</a>
and .Net 3.0
and .Net 3.1
</div>
</footer>

Expand Down
2 changes: 1 addition & 1 deletion WebApp/WebApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>


Expand Down
18 changes: 9 additions & 9 deletions docs/local-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Prerequisites
Install the following

1. [.Net SDK 3](https://dotnet.microsoft.com/en-us/download/dotnet/3.0)
1. [.Net SDK 3.1](https://dotnet.microsoft.com/en-us/download/dotnet/3.1)
1. libman with `dotnet tool install -g Microsoft.Web.LibraryManager.Cli`
1. [docker desktop](https://www.docker.com/products/docker-desktop/)

Expand All @@ -21,24 +21,24 @@ Currently no unit tests exist 🐒, also dafuc is [MS Test](https://carlpaton.gi
1. `cd .\IntegrationTests\`
1. run `dotnet test`

## Deploy Docker Registry
This deploys to https://hub.docker.com/
## Manual Deploy Docker Registry
This deploys to https://hub.docker.com/, merging to master also triggers [this action](https://github.com/carlpaton/RedisAdministrator/actions) which publishes [latest tag](https://hub.docker.com/r/carlpaton/redis-administrator/tags).

I last did this with an integration from Github to Docker.com but they have since canned this feature and put it behind a paywall, I'll update here after I figure out how to do it.

1. build image with `docker build -t redis-administrator:dev .`
1. run it locally as `docker run --name red-admin-dev -d -p 8082:80 --network redis-bridge-network --env REDIS_CONNECTION=red-srv,allowAdmin=true redis-administrator:dev`
1. build image with `docker build -t redis-administrator:develop .`
1. run it locally as `docker run --name red-admin-develop -d -p 8082:80 --network redis-bridge-network --env REDIS_CONNECTION=red-srv,allowAdmin=true redis-administrator:develop`
1. browse to http://localhost:8082

Now actually deploy

1. `docker login`, one time device confirmation opens docker.com for you to confirm
1. tag the image `docker tag redis-administrator:dev carlpaton/redis-administrator:dev`
1. now push `docker push carlpaton/redis-administrator:dev`
1. tag the image `docker tag redis-administrator:develop carlpaton/redis-administrator:develop`
1. now push `docker push carlpaton/redis-administrator:develop`
1. browse and check the tag exists at https://hub.docker.com/r/carlpaton/redis-administrator/

Test the deployed image

1. delete local image tagged as `carlpaton/redis-administrator:dev`
1. run locally as `docker run --name red-admin-deploy -d -p 8083:80 --network redis-bridge-network --env REDIS_CONNECTION=red-srv,allowAdmin=true carlpaton/redis-administrator:dev` which should then pull from docker hub
1. delete local image tagged as `carlpaton/redis-administrator:develop`
1. run locally as `docker run --name red-admin-deploy -d -p 8083:80 --network redis-bridge-network --env REDIS_CONNECTION=red-srv,allowAdmin=true carlpaton/redis-administrator:develop` which should then pull from docker hub
1. browse to http://localhost:8083