Skip to content

Commit

Permalink
Added Dockerfile at the repository root level to support docker image…
Browse files Browse the repository at this point in the history
… build using Github URL
  • Loading branch information
nileshgnagepatil committed Sep 21, 2023
1 parent 7a7c18a commit dec7359
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 28 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/docker-content-regression-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Run regression tests
on:
pull_request:
branches:
- master
- main
jobs:
build-test-scan:
name: Build image and regression test
runs-on: ubuntu-latest
env:
CPD_GOOGLEANALYTICSTAG: ${{secrets.TF_VAR_CPD_GOOGLEANALYTICSTAG}}
CPD_SPACE_ID: ${{secrets.TF_VAR_CPD_SPACE_ID}}
CPD_PREVIEW_KEY: ${{secrets.TF_VAR_CPD_PREVIEW_KEY}}
CPD_DELIVERY_KEY: ${{secrets.TF_VAR_CPD_DELIVERY_KEY}}
CPD_CLARITY: ${{secrets.TF_VAR_CPD_CLARITY}}
steps:
- uses: actions/checkout@v3

- name: Build the Docker App Image
run: cd Childrens-Social-Care-CPD; docker build https://github.com/DFE-Digital/childrens-social-care-cpd.git#Feature/ContainerizeRegressionTests --tag childrens-social-care-cpd:ContainerizeRegressionTests
- name: Run the content regression tests
run: cd browser-tests/content-regression-tests; docker-compose up --exit-code-from content-regression-tests

- uses: actions/upload-artifact@v3
name: Playwright report
if: always()
with:
name: playwright-report
retention-days: 7
path: |
${{ github.workspace }}/browser-tests/content-regression-tests/playwright-report
- name: Run Tidy up
if: always()
run: cd browser-tests/content-regression-tests; docker-compose down --volumes
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["Childrens-Social-Care-CPD.csproj", "."]
RUN dotnet restore "./Childrens-Social-Care-CPD.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "Childrens-Social-Care-CPD.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Childrens-Social-Care-CPD.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ARG VCSREF=0
ENV VCS-REF=$VCSREF
ARG VCSTAG=0.0.0
ENV VCS-TAG=$VCSTAG
ENTRYPOINT ["dotnet", "Childrens-Social-Care-CPD.dll"]
24 changes: 1 addition & 23 deletions browser-tests/content-regression-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["Childrens-Social-Care-CPD.csproj", "."]
RUN dotnet restore "./Childrens-Social-Care-CPD.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "Childrens-Social-Care-CPD.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Childrens-Social-Care-CPD.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Childrens-Social-Care-CPD.dll"]
EXPOSE 80

FROM mcr.microsoft.com/playwright:v1.37.1-jammy
FROM mcr.microsoft.com/playwright:v1.36.0-jammy

WORKDIR /app

Expand Down
7 changes: 2 additions & 5 deletions browser-tests/content-regression-tests/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
version: "3.4"
services:
children-social-care-cpd:
build:
context: https://github.com/DFE-Digital/childrens-social-care-cpd.git#${CPD_BRANCH_OR_TAG_NAME}
ports:
- "8080:80"
image: childrens-social-care-cpd:ContainerizeRegressionTests
environment:
- CPD_AZURE_ENVIRONMENT=${CPD_AZURE_ENVIRONMENT}
- CPD_CLARITY=${CPD_CLARITY}
Expand All @@ -22,7 +19,7 @@ services:
build:
context: ./
environment:
- PLAYWRIGHT_BASE_URL=http://children-social-care-cpd:80
- PLAYWRIGHT_BASE_URL=http://children-social-care-cpd
- CI=1
volumes:
- ./playwright-report:/app/playwright-report/
Expand Down

0 comments on commit dec7359

Please sign in to comment.