fix dotnet tools missing in migration bundle in cd
This commit is contained in:
+9
-17
@@ -78,33 +78,25 @@ jobs:
|
|||||||
migrate:
|
migrate:
|
||||||
needs: build-and-push
|
needs: build-and-push
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# Checkout/setup-* are Node actions and must run on the job host (act_runner
|
# Checkout must run on the job host (Node). Do not use job-level container:.
|
||||||
# default image). Do not set job-level container: — that replaced the host
|
# Build the EF bundle via Dockerfile --target migrate (context upload), not
|
||||||
# with dotnet/sdk (no node) and broke checkout. Use docker run for the SDK
|
# docker run -v — under act_runner bind mounts resolve on the Docker host.
|
||||||
# instead; the runner already needs Docker for build-and-push.
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build migration bundle
|
- name: Build migration bundle
|
||||||
run: |
|
run: |
|
||||||
docker run --rm \
|
docker build -f VigilCareClinicalAPI/Dockerfile --target migrate \
|
||||||
-v "$PWD:/src" \
|
-t vigilcare-migrate-bundle:local .
|
||||||
-w /src \
|
cid=$(docker create vigilcare-migrate-bundle:local)
|
||||||
-e HOME=/tmp \
|
docker cp "$cid:/out/migrate-api" ./migrate-api
|
||||||
mcr.microsoft.com/dotnet/sdk:8.0 \
|
docker rm "$cid"
|
||||||
bash -euo pipefail -c '
|
|
||||||
dotnet tool install --global dotnet-ef --version 8.0.4 \
|
|
||||||
|| dotnet tool update --global dotnet-ef --version 8.0.4
|
|
||||||
export PATH="$PATH:/tmp/.dotnet/tools"
|
|
||||||
bash ./scripts/build-api-migration-bundle.sh
|
|
||||||
'
|
|
||||||
cp -f ./artifacts/migrate-api ./migrate-api
|
|
||||||
chmod +x ./migrate-api
|
chmod +x ./migrate-api
|
||||||
|
|
||||||
# Runs while the previous release is still serving traffic, so every
|
# Runs while the previous release is still serving traffic, so every
|
||||||
# migration must be backwards-compatible with the outgoing image.
|
# migration must be backwards-compatible with the outgoing image.
|
||||||
# See Step 6 — expand-then-contract.
|
# See Step 6 — expand-then-contract.
|
||||||
# Self-contained linux-x64 binary — runs on the host, not inside the SDK image.
|
# Self-contained linux-x64 binary — runs on the job host.
|
||||||
- name: Apply migrations
|
- name: Apply migrations
|
||||||
run: ./migrate-api --connection "${{ secrets.PG_CONNECTION_DDL }}"
|
run: ./migrate-api --connection "${{ secrets.PG_CONNECTION_DDL }}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
# Multi-stage API image + EF migration bundle.
|
||||||
|
# docker build -f VigilCareClinicalAPI/Dockerfile . → runtime (default)
|
||||||
|
# docker build -f VigilCareClinicalAPI/Dockerfile --target migrate . → /out/migrate-api
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS src
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# Restore layer — copy only project files so NuGet restore is cached
|
# Restore layer — copy only project files so NuGet restore is cached
|
||||||
@@ -12,6 +15,8 @@ RUN dotnet restore VigilCareClinicalAPI/VigilCareClinicalAPI.csproj
|
|||||||
COPY VigilCare.ClinicalContracts/ VigilCare.ClinicalContracts/
|
COPY VigilCare.ClinicalContracts/ VigilCare.ClinicalContracts/
|
||||||
COPY VigilCare.Simulation.Core/ VigilCare.Simulation.Core/
|
COPY VigilCare.Simulation.Core/ VigilCare.Simulation.Core/
|
||||||
COPY VigilCareClinicalAPI/ VigilCareClinicalAPI/
|
COPY VigilCareClinicalAPI/ VigilCareClinicalAPI/
|
||||||
|
|
||||||
|
FROM src AS build
|
||||||
RUN dotnet publish VigilCareClinicalAPI/VigilCareClinicalAPI.csproj \
|
RUN dotnet publish VigilCareClinicalAPI/VigilCareClinicalAPI.csproj \
|
||||||
-c Release -o /app/publish --no-restore
|
-c Release -o /app/publish --no-restore
|
||||||
|
|
||||||
@@ -24,6 +29,21 @@ RUN sed -i \
|
|||||||
-e 's/"ApiKey": "dev-integration[^"]*"/"ApiKey": ""/' \
|
-e 's/"ApiKey": "dev-integration[^"]*"/"ApiKey": ""/' \
|
||||||
/app/publish/appsettings.json
|
/app/publish/appsettings.json
|
||||||
|
|
||||||
|
# Self-contained EF bundle for CD (docker build --target migrate).
|
||||||
|
# Prefer docker build over docker run -v on act_runner — bind mounts resolve
|
||||||
|
# on the Docker host, not the job workspace.
|
||||||
|
FROM src AS migrate
|
||||||
|
RUN dotnet tool install --global dotnet-ef --version 8.0.4 \
|
||||||
|
&& export PATH="$PATH:/root/.dotnet/tools" \
|
||||||
|
&& mkdir -p /out \
|
||||||
|
&& dotnet ef migrations bundle \
|
||||||
|
--project VigilCareClinicalAPI \
|
||||||
|
--startup-project VigilCareClinicalAPI \
|
||||||
|
--configuration Release \
|
||||||
|
--self-contained -r linux-x64 \
|
||||||
|
--output /out/migrate-api \
|
||||||
|
--force
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user