Azure / Azure/azure-functions-core-tools

func init --docker-only generated Dockerfile should include WORKDIR command

Open
#2,036 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.5k
Forks
498
Avg merge
5d 4h
Merged PRs (30d)
15

Description

func init --docker-only generate Dockerfile content is:
``` dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS installer-env

COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
mkdir -p /home/site/wwwroot && \
dotnet publish *.csproj --output /home/site/wwwroot

# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice
FROM mcr.microsoft.com/azure-functions/dotnet:3.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]
```
My image using this Dockerfile is working when run in Ubuntu
but it's not working when run in CentOS
I use this [reference] (https://stackoverflow.com/questions/51598627/access-to-the-path-proc-1-map-files-is-denied-net-core-2-1-centos-7) to resolve my problem.

Correct Dockerfile is
``` dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS installer-env

COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
mkdir -p /home/site/wwwroot && \
dotnet publish *.csproj --output /home/site/wwwroot

# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice
FROM mcr.microsoft.com/azure-functions/dotnet:3.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true

WORKDIR /home/site/wwwroot
COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]
```
adding this line **WORKDIR /home/site/wwwroot**

Contributor guide

Open the contributing guide

Research direction

Start at the func init --docker-only entry point and locate the Dockerfile generation template or path. Compare its output with the Dockerfile shown in the issue, add the requested WORKDIR line, and check any existing generation tests or regenerate a sample to confirm the output.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.