anemoneyy
anemoneyy

Reputation: 1

Azure Linux Web App: ERROR - Container didn't respond to HTTP pings on port: 7007, failing site start

I have an Azure web app running an image from an Azure container registry. The container starts up just fine, but the site fails to start.

I'm running this on port 7007 and have the environment variable WEBSITES_PORT=7007 set.

My app configuration has the correct settings to run on port 7007 and I've exposed the port in my Dockerfile.

Dockerfile code: https://backstage.io/docs/deployment/docker/#multi-stage-build

Here is the full error:

ERROR - Container for site has exited, failing site start
  Ok
2024-06-13T17:05:48.847
ERROR - Container didn't respond to HTTP pings on port: 7007, failing site start. See container logs for debugging.
  Ok
2024-06-13T17:05:48.849
INFO  - Stopping site because it failed during startup.

The site was working on port 7007 with no issue, but started failing about two weeks ago. I'm happy to share more code or context. Thanks!

Upvotes: 0

Views: 480

Answers (1)

Sirra Sneha
Sirra Sneha

Reputation: 1164

I created a backstage application following the documentation you've provided and successfully deployed to the azure app service through Azure container registry.

To setup a multistage docker build, I've updated the dockerfile and .dockerignore files as below.

Dockerfile:

FROM node:18-bookworm-slim AS packages
WORKDIR /app
COPY package.json yarn.lock ./
COPY packages packages
COPY plugins plugins
RUN find packages \! -name "package.json" -mindepth 2 -maxdepth 2 -exec rm -rf {} \+
FROM node:18-bookworm-slim AS build
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
    --mount=type=cache,target=/var/lib/apt,sharing=locked \
    apt-get update && \
    apt-get install -y --no-install-recommends python3 g++ build-essential && \
    yarn config set python /usr/bin/python3
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
    --mount=type=cache,target=/var/lib/apt,sharing=locked \
    apt-get update && \
    apt-get install -y --no-install-recommends libsqlite3-dev
USER node
WORKDIR /app
COPY --from=packages --chown=node:node /app .
RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000 \
    yarn install --frozen-lockfile --network-timeout 600000
COPY --chown=node:node . .
RUN yarn tsc
RUN yarn --cwd packages/backend build
RUN mkdir packages/backend/dist/skeleton packages/backend/dist/bundle \
    && tar xzf packages/backend/dist/skeleton.tar.gz -C packages/backend/dist/skeleton \
    && tar xzf packages/backend/dist/bundle.tar.gz -C packages/backend/dist/bundle
FROM node:18-bookworm-slim
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
    --mount=type=cache,target=/var/lib/apt,sharing=locked \
    apt-get update && \
    apt-get install -y --no-install-recommends python3 g++ build-essential && \
    yarn config set python /usr/bin/python3
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
    --mount=type=cache,target=/var/lib/apt,sharing=locked \
    apt-get update && \
    apt-get install -y --no-install-recommends libsqlite3-dev
USER node
WORKDIR /app
COPY --from=build --chown=node:node /app/yarn.lock /app/package.json /app/packages/backend/dist/skeleton/ ./
RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000 \
    yarn install --frozen-lockfile --production --network-timeout 600000
COPY --from=build --chown=node:node /app/packages/backend/dist/bundle/ ./
COPY --chown=node:node app-config.yaml ./
ENV NODE_ENV production
CMD ["node", "packages/backend", "--config", "app-config.yaml"]

.dockerignore:

dist-types
node_modules
packages/*/dist
packages/*/node_modules
plugins/*/dist
plugins/*/node_modules

I ran the below commands to build and run backstage app.

docker image build -t backstage .
docker run -it -p 7007:7007 backstage

I've used below commands to push the docker image to Azure container registry.

az acr login -n <container-registry>
docker tag <image-name> <container-registry>.azurecr.io/<image-name>:<tag>
docker push <container-registry>.azurecr.io/<image-name>:<tag>

while creating the azure web app, select publish option as a container -> Azure container registry.

I got the same issue when I only mentioned port in my environment variable.

So, make sure that your port is set to 7007 as shown below. enter image description here

Output after deployment:

enter image description here

Upvotes: 0

Related Questions