I'm trying to create azure queue listener in docker and deploy it as an azure function.
Azure runs my docker with command similar to following:
docker run -d -p 16506:8081 --name queue-listener_0 -e PORT=8081 ...
The only thing that I need to do is to get that port variable and put it to func start --port $PORT field in entrypoint script, but the problem is that the bash doesn't see variables put through -e key.
Dockerfile:
FROM tarampampam/node:10.10-alpine as buildContainer
COPY package.json package-lock.json entrypoint.sh host.json extensions.csproj proxies.json /app/
COPY /QueueTrigger/function.json /app/
#COPY /app/dist /app/dist
### only for local launch
#COPY /local.settings.json /app
WORKDIR /app
RUN npm install
COPY . /app
RUN npm run build
FROM mcr.microsoft.com/azure-functions/node:2.0
WORKDIR /app
ENV AzureWebJobsScriptRoot=/app
ENV AzureWebJobs_ExtensionsPath=/app/bin
# Copy dependency definitions
COPY --from=buildContainer /app/package.json /app/
# Get all the code needed to run the app
COPY --from=buildContainer /app/dist /app/
COPY --from=buildContainer /app/function.json /app/QueueTrigger/
COPY --from=buildContainer /app/bin /app/bin
COPY --from=buildContainer /app/entrypoint.sh /app
COPY --from=buildContainer /app/host.json /app
COPY --from=buildContainer /app/extensions.csproj /app
COPY --from=buildContainer /app/proxies.json /app
COPY --from=buildContainer /app/resources /app/resources
### only for local launch
#COPY --from=buildContainer /app/local.settings.json /app
RUN chmod 755 /app/entrypoint.sh
COPY --from=buildContainer /app/node_modules /app/node_modules
RUN npm i -g azure-functions-core-tools@core --unsafe-perm true
RUN apt-get update && apt-get install -y ghostscript && gs -v
# Serve the app
ENTRYPOINT ["sh", "entrypoint.sh"]
Entrypoint:
#!/bin/bash
func start --port $PORT
func is more for local development.
The mcr.microsoft.com/azure-functions/node:2.0 image already has the runtime packaged with the default entrypoint set to start it. You really don't need func here.
But, if ever required, even with just the runtime, you can customize the port
RUN chmod 755 /app/entrypoint.sh
RUN npm i -g azure-functions-core-tools@core --unsafe-perm true
# Serve the app
ENTRYPOINT ["sh", "entrypoint.sh"]
docker run -d -p 16506:8081 --name queue-listener_0 -e ASPNETCORE_URLS=http://+:8081 ...
Note that
local.settings.jsonwon't be picked up by the runtime. Your App Settings would have to be set manually as environment variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With