Skip to content

Commit af49022

Browse files
Robu6/libs nuget example (#68)
* Adding libs examples. * Add libs action to build stage. * correct typo * run.sh assembly names. * secrets. * CCM-11007: Fixing log destination for Splunk forwarding (#58) * Robu6/libs nuget example (#57) * Adding libs examples. * Add libs action to build stage. * correct typo * run.sh assembly names. * rebased to main. * .... * <<< left in * Adding other example poc libs. * timeouts of actions increased to 10m from 3m. * version copy to abstract folder. * version file not in libs on github. * find .version and print on pub. * debugging in build. * include .version in libs - artifact hidden files. * correct data nuget package name. * Trying the docker actions. * Trying the docker actions. * Trying the docker actions. * Trying the docker actions. * Adding docker publish from artefact --------- Co-authored-by: sidnhs <[email protected]>
1 parent abecf18 commit af49022

File tree

4 files changed

+76
-2
lines changed

4 files changed

+76
-2
lines changed

.github/actions/build-libraries/action.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,22 @@ runs:
5151
path: "src/server/host/bin/Release"
5252
name: libs-host-${{ inputs.version }}
5353
include-hidden-files: true
54+
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@v3
57+
58+
- name: Build and export
59+
uses: docker/build-push-action@v6
60+
with:
61+
context: src/server
62+
file: src/server/Dockerfile
63+
tags: |
64+
ghcr.io/nhsdigital/libshostdocker:latest
65+
# ghcr.io/nhsdigital/libshostdocker:${{ inputs.version }}
66+
outputs: type=docker,dest=${{ runner.temp }}/myimage.tar
67+
68+
- name: Upload artifact
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: libs-host-docker-${{ inputs.version }}
72+
path: ${{ runner.temp }}/myimage.tar

.github/workflows/stage-5-publish.yaml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ jobs:
200200
asset_content_type: "application/gzip"
201201

202202

203-
### PUBLISH DOCKER
203+
### PUBLISH DOCKER - THIS NEEDS CHANGING TO DO THE DOCKER BUILD IN THE BUILD STAGE AND ARTIFACT IT. SEE publishlibhostdocker below how how and the buildlibs action.
204204
publishdocker:
205205
name: "Publish docker packages"
206206
runs-on: ubuntu-latest
@@ -224,7 +224,6 @@ jobs:
224224
docker build . -t ghcr.io/nhsdigital/nhsnotifysupplierserver:latest
225225
echo $CR_PAT | docker login ghcr.io -u nhs-notify-supplier-api --password-stdin
226226
docker push ghcr.io/nhsdigital/nhsnotifysupplierserver:latest
227-
228227
env:
229228
CR_PAT: ${{ secrets.GITHUB_TOKEN }}
230229
@@ -582,3 +581,28 @@ jobs:
582581
env:
583582
TEST_NUGET_VERSION: ${{ steps.set-nuget-version.outputs.TEST_NUGET_VERSION }}
584583
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
584+
585+
586+
587+
### PUBLISH LIBS host docker
588+
publishlibhostdocker:
589+
name: "Publish libs host docker"
590+
runs-on: ubuntu-latest
591+
needs: [publish]
592+
permissions:
593+
packages: write
594+
contents: read
595+
steps:
596+
- name: "Get the artefacts"
597+
uses: actions/download-artifact@v4
598+
with:
599+
path: .
600+
name: libs-host-docker-${{ inputs.version }}
601+
602+
- run: |
603+
docker load --input ${{ runner.temp }}/myimage.tar
604+
docker image ls -a
605+
echo $CR_PAT | docker login ghcr.io -u nhs-notify-supplier-api --password-stdin
606+
docker push ghcr.io/nhsdigital/libshostdocker:latest
607+
env:
608+
CR_PAT: ${{ secrets.GITHUB_TOKEN }}

src/server/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Multi-stage Dockerfile for .NET 8 Web API
2+
# Build stage
3+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
4+
WORKDIR /src
5+
6+
# Copy solution and restore as distinct layers
7+
COPY .version ./
8+
COPY build.sh ./
9+
COPY server.sln ./
10+
COPY host/host.csproj ./host/
11+
COPY abstractions/abstractions.csproj ./abstractions/
12+
COPY data/data.csproj ./data/
13+
COPY letter/letter.csproj ./letter/
14+
COPY . .
15+
16+
RUN ./build.sh
17+
18+
# Runtime stage
19+
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
20+
WORKDIR /app
21+
COPY --from=build src/host/bin/Release/net8.0/publish .
22+
23+
# Expose port (change if your app uses a different port)
24+
EXPOSE 8080
25+
26+
# Set environment variables (optional)
27+
# ENV ASPNETCORE_URLS=http://+:80
28+
RUN ls -la
29+
30+
ENTRYPOINT ["./run.sh"]

src/server/host/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ SuppliersApi__Letters=true \
44
SuppliersApi__Data=true \
55
SuppliersApi__Assemblies__0="nhs.notify.suppliers.api.letter" \
66
SuppliersApi__Assemblies__1="nhs.notify.suppliers.api.data" \
7+
ASPNETCORE_ENVIRONMENT="Development" \
78
dotnet nhs.notify.suppliers.api.host.dll

0 commit comments

Comments
 (0)