Skip to content

Commit

Permalink
add back docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
kaibocai committed Nov 28, 2023
1 parent b9a12bb commit 4c800bb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
continue-on-error: true

- name: Setup azure functions runtime
run: endtoendtests/e2e-test-setup.ps1 -DockerfilePath endtoendtests/Dockerfile
run: samples-azure-functions/e2e-test-setup.ps1 -DockerfilePath samples-azure-functions/Dockerfile
shell: pwsh

- name: Sample Tests with Gradle
Expand Down
5 changes: 5 additions & 0 deletions samples-azure-functions/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM mcr.microsoft.com/azure-functions/java:4-java11

COPY samples-azure-functions/build/azure-functions/azure-functions-sample/ /home/site/wwwroot/
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
42 changes: 42 additions & 0 deletions samples-azure-functions/e2e-test-setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Installing PowerShell: https://docs.microsoft.com/powershell/scripting/install/installing-powershell

param(
[Parameter(Mandatory=$true)]
[string]$DockerfilePath,
[string]$ImageName="dfapp",
[string]$ContainerName="app",
[switch]$NoSetup=$false,
[switch]$NoValidation=$false,
[string]$AzuriteVersion="3.20.1",
[int]$Sleep=30
)

$ErrorActionPreference = "Stop"

if ($NoSetup -eq $false) {
# Build the docker image first, since that's the most critical step
Write-Host "Building sample app Docker container from '$DockerfilePath'..." -ForegroundColor Yellow
docker build -f $DockerfilePath -t $ImageName --progress plain .

# Next, download and start the Azurite emulator Docker image
Write-Host "Pulling down the mcr.microsoft.com/azure-storage/azurite:$AzuriteVersion image..." -ForegroundColor Yellow
docker pull "mcr.microsoft.com/azure-storage/azurite:${AzuriteVersion}"

Write-Host "Starting Azurite storage emulator using default ports..." -ForegroundColor Yellow
docker run --name 'azurite' -p 10000:10000 -p 10001:10001 -p 10002:10002 -d "mcr.microsoft.com/azure-storage/azurite:${AzuriteVersion}"

# Finally, start up the smoke test container, which will connect to the Azurite container
docker run --name $ContainerName -p 8080:80 -it --add-host=host.docker.internal:host-gateway -d `
--env 'AzureWebJobsStorage=UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://host.docker.internal' `
--env 'WEBSITE_HOSTNAME=localhost:8080' `
$ImageName
}

if ($sleep -gt 0) {
# The container needs a bit more time before it can start receiving requests
Write-Host "Sleeping for $Sleep seconds to let the container finish initializing..." -ForegroundColor Yellow
Start-Sleep -Seconds $Sleep
}

# Check to see what containers are running
docker ps

0 comments on commit 4c800bb

Please sign in to comment.