How can I deploy a graphql API with docker-compose in azure

2020-11-21T22:46:25

I have problems trying to deploy a graphql API to Azure web apps (I don't know if it's the right place but here's my case)

My expectation

I want to deploy a graphql API using a docker-compose file with azure-container-registry. I use docker for local development and everything is correct. In the docker-compose file I define my local enviroment variables, and in my node.js API I reference this variables using process.env.{variable_name}

My problem

In production, I got a blank page (with no visible error log) when I was trying to access my currently deployed app link (For example https://myapp.azurewebsites.net/graphql) enter image description here

Here's the stack of my graphql API: Apollo Server, Nodejs, Docker compose (I used apollo-server-express)

What I tried

I used Azure pipelines to deploy the front-end repository of my application and configured a GitHub action too. So I decided to use the same logic with my backend repository.

I already deployed my mongodb using Atlas.

I put my docker-compose-prod.yml variables between ${ } symbols because I guess this is necessary for the azure pipelines to detect where I'm going to put my variables

This is how it looks like.


# Docker
# Build and push an image to Azure Container Registry
# https://learn.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
- main

resources:
- repo: self

variables:
  # Container registry service connection established during pipeline creation
  dockerRegistryServiceConnection: <.....>
  imageRepository: 'myimagereposity'
  containerRegistry: 'mycontainerregistry.azurecr.io'
  dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile.dev'
  tag: '$(Build.BuildId)'
  dockerComposeFile: '$(Build.SourcesDirectory)/docker-compose-prod.yml'
  projectName: $(Build.Repository.Name)
  # Agent VM image name
  vmImageName: 'ubuntu-latest'

stages:
- stage: Build
  displayName: Build and push stage
  jobs:  
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
    steps:
    - task: DockerCompose@0
      inputs:
        containerregistrytype: 'Azure Container Registry'
        azureSubscription: 'Suscripcion developer 1(id-subs)'
        azureContainerRegistry: '{"loginServer":"mycontainerregistry.azurecr.io", "id" : "/subscriptions/id-subs/resourceGroups/proyecto-final/providers/Microsoft.ContainerRegistry/registries/mycontainername"}'
        dockerComposeFile: '**/docker-compose-prod.yml'
        dockerComposeFileArgs: |
          DATABASE_URL=mongodb+srv://mydb-user:$(dbpassword)@cluster0.defvz.mongodb.net/$(dbname)?retryWrites=true&w=majority
          AWS_ACCESS_ID=$(AWS_ACCESS_ID)
          AWS_SECRET_KEY=$(AWS_SECRET_KEY)
          AWS_REGION=$(AWS_REGION)
          S3_BUCKET_NAME=$(S3_BUCKET_NAME)
          GOOGLE_APPLICATION_CREDENTIALS=$(GOOGLE_APPLICATION_CREDENTIALS)
        action: 'Build services'

This is my Dockerfile

FROM node:12-alpine 

EXPOSE 8080

WORKDIR /usr/src/app 

COPY package*.json ./

RUN npm install --silent 

COPY . .

CMD [ "npm", "run", "debug" ]

This is my docker-compose-prod.yml


version: '3.7'

services:
  api:
    container_name: 'saaga-api'
    restart: 'always'
    build:
      context: .
      dockerfile: 'Dockerfile.prod'
    volumes:
      # - /usr/src/app/node_modules
      - '.:/usr/src/app'
    environment:
      NODE_ENV: production
      ORIGIN: 'https://myapp.azurewebsites.net'
      PORT: 8080
      DATABASE_URL: ${DATABASE_URL}
      AWS_ACCESS_ID: ${AWS_ACCESS_ID}
      AWS_SECRET_KEY: ${AWS_SECRET_KEY}
      AWS_REGION: ${AWS_REGION}
      S3_BUCKET_NAME: ${S3_BUCKET_NAME}
      GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS}
    ports:
      - 8080:8080
      - 9229:9229
    links:
      - db
  db:
    container_name: 'mongodb'
    image: 'mongo'
    ports:
      - 27017:27017

Someone knows what I'm missing or what I'm doing badly? The app works well for the local environment, the problem is only in production.

enter image description here

Copyright License:
Author:「Roberto」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/64944349/how-can-i-deploy-a-graphql-api-with-docker-compose-in-azure

About “How can I deploy a graphql API with docker-compose in azure” questions

I have problems trying to deploy a graphql API to Azure web apps (I don't know if it's the right place but here's my case) My expectation I want to deploy a graphql API using a docker-compose file ...
I have created an angular site that uses API written in node js and graph al using mysql data base. I want to deploy it in azure. I am new to azure deployment can any one give me suggestion on how to
I have made a backend API that connects to the sql that is also hosted on my azure account, however im not sure how to deploy this api on azure and make it available on there so that i can deploy my
I'm creating APIs on the Azure APIM with GraphQL. This is still on preview so until now I only can create them clicking in the portal or using the Azure API Rest with a PUT request. I'm trying to m...
Can anyone has an idea about how to deploy prefect UI and backed on azure web app server using docker/docker-compose? I need to deploy prefect workflow on the azure web app service. Thanks for your...
I have been trying to deploy a backend api service made with graphql api and express to Amazon web services. This is my folder structure Graphql-api -src -index.js -serverl...
I want to deploy monitoring dashboards using Grafana as web apps using Azure-cloud and share them with my team members. But I found some problem: (1) In Docker-compose, Grafana needs volumes to s...
I already developed Node.js API project which use docker-compose up for start. Now im trying to deploy the project to remote Ubuntu host via ssh. Also I installed node.js and docker on remote host....
I am new to graphql and wanted to know how to creating a swagger out of graphql endpoint. Will any features of GraphQL be restricted if I use a swagger? I need the swagger to host my api(s) behind...
Azure APIM now support graphql passthrough (GA in last Build). This is fine but still no documentation on how it can be imported programmatically. We are doing it manually via Portal once Terraform...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.