I have a node.js website that runs fine when I run it locally with node server.js. I'm trying to deploy it online with GCP. I created a project, enabled app engine API, and gave my '#cloudbuild.gserviceaccount.com' account app engine deployer role permissions.
I also added a cloudbuild.yaml file to my repo:
steps:
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
Now If I run gcloud app deploy , my build gets triggered, but appears to me causing an infinite loop of builds? For example, starting out my build log looks like this (nothing currently running):
i run gcloud app deploy and it begins a new build (1a19d9ba):
But something with this build keeps triggering new builds? in my local computer terminal, the output I get for running gcloud app deploy keeps triggering new builds:
$ gcloud app deploy
Services to deploy:
descriptor: [/mnt/c/Users/marti/Documents/projects/martinbarker/app.yaml]
source: [/mnt/c/Users/marti/Documents/projects/martinbarker]
target project: [martinbarker2]
target service: [default]
target version: [20201003t165547]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)? y
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [1a19dxxxxx627d].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/1axxx
------------------------------------------------- REMOTE BUILD OUTPUT --------------------------------------------------starting build "1a19xxxxxx27d"
FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.20xxx47:latest#160xxx288
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.202xxx547:latest#16xxx88...
| [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:
descriptor: [/workspace/app.yaml]
source: [/workspace]
target project: [martinbarker2]
target service: [default]
target version: [20201003t235749]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?
WARNING: Unable to verify that the Appengine Flexible API is enabled for project [martinbarker2]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [d0d0xxx9a987].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/d0d0xxx987?project=114941087848
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "d0d0dxxx987"
FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.20201xxx49:latest#160176947xx11
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.20xxx:latest#16xxx548211...
\ [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:
descriptor: [/workspace/app.yaml]
source: [/workspace]
target project: [martinbarker2]
target service: [default]
target version: [20201003t235818]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?
WARNING: Unable to verify that the Appengine Flexible API is enabled for project [martinbarker2]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [683bb8cxxx0368f36].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/683bxxxf36?project=114xx48
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "683bb8xx368f36"
FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.2020xxx18:latest#16xxx376
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.202xxx18:latest#16xx376...
| [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:
descriptor: [/workspace/app.yaml]
source: [/workspace]
target project: [martinbarker2]
target service: [default]
target version: [20201003t235843]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?
WARNING: Unable to verify that the Appengine Flexible API is enabled for project [martinbarker2]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [feecxxx3cd86].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/feexxx87848
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "feec9xxxx3cd86"
FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.2020100xxx082
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.202xxx82...
- [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:
descriptor: [/workspace/app.yaml]
source: [/workspace]
target project: [martinbarker2]
target service: [default]
target version: [20201003t235909]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?
This goes on, and now I have many more builds:
My app.yaml:
runtime: custom
env: flex
manual_scaling:
instances: 2
is it something with my cloudbuild.yaml file? I dont have a dockerfile in my folder
"It's not a bug; it's a feature!" But it's not documented, or I didn't find where! Actually, with App Engine Flex custom runtime, you will create a container. You can define either a cloudbuild.yaml file or a Dockerfile to describe the container creation. And this container is created with Cloud Build.
For information, if you set a specific language runtime, Buildpack is used to create the container, still on Cloud Build; however a Dockerfile is no longer required
So, in your case, as you describe, you have a cloudbuild.yaml file that deploys an App Engine flex custom runtime, that call a Cloud Build to build the container, with the cloudbuild.yaml file in parameters that deploys..... (loop!)
Ok, now, how to fix this? 2 solutions
Change the name of your cloudbuild.yaml file to not match this default naming (cloudbuild-noloop.yaml for example). Set this name in the trigger configuration or in the gcloud builds submit --config=cloudbuild-noloop.yaml command
Update your cloudbuild.yaml deploy step like this
steps:
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy","--ignore-file=cloudbuild.yaml"]
Related
I am using Azure SWA CLI 1.0.2 on Node 16.15.0 in WSL2 on Windows 11
Starting with a "Hello World" style deployment. E.g. no CI/CD, no Github, no repost, commits, PRs, etc.
I have my dist folder with a simple Hello World style index.html file. I can view it with the SWA dev server.
When I attempt to deploy with npx #azure/static-web-apps-cli deploy ./dist -S <REDACTED> --no-use-keychain I get the following output
Welcome to Azure Static Web Apps CLI (1.0.2)
Deploying front-end files from folder:
/myproject/dist
Checking Azure session...
✔ Successfully logged into Azure!
✔ Choose your tenant › <REDACTED>
✔ Successfully logged into Azure tenant: <REDACTED>
✔ Saved project credentials in .env file.
Checking project settings...
✔ Choose your Static Web App › >> Create a new application
✔ Choose a project name: … delme
✔ Project created successfully!
✔ Successfully setup project!
Deploying to environment: preview
Deploying project to Azure Static Web Apps...
⠙ Looking for event info
But it just sits on "Looking for event info" forever.
I have also tried with deployment tokens, killing all resources in my AZ account and starting over, etc.
I have a very weird (and I suppose easy to fix) problem :) I am trying to have a working CI/CD pipeline in Azure. For this purpose, I have a repository in Azure devops and build and release pipeline created. I am publishing docker images to Azure Container Registry and during release, I am pulling this image (or at least - I am trying because it doesn't work) and I am trying to publish it on Webapp for containers. The "app" in my case it is SingalR hub on .NET Core 3.1 (but I don't suppose it makes a difference in the problem I am having)
If somebody wants to know in details how did i configure it - here is the tutorial i did use:
https://wikiazure.com/devops/azure-devops-automate-your-release-pipeline-to-provision-a-docker-container-to-azure-web-app-for-containers/
There were some doubts/differences in the tutorial (for example - why initially in the tutorial web app is being configured on Docker hub, when in fact it is using ACR. And why to connect to ACR the tutorial uses Azure Resource Manager connection (And not dedicated Docker container --> ACR connetion) And why later on in build pipeline there is some weird id set for dockerRegistryServiceConnection (i am giving in this place name of my ACR docker service connection)
But the whole build pipeline is working. It is publishing image to ACR. Everything is fine till this step.
The problem starts when I want to publish Azure WebApp with this image. The problem is with ... TAGS :) They are mismatching. I have automatic CI/CD - so when i push some change to the repo i see that release pipeline is working. It is creating the image in the ACR. Then i see, that release pipeline is running. Everything is "correct" - meaning no error are seen and the release is green.
But when i go to App service and Container settings i see from logs:
2020-04-21 18:02:28.321 INFO - Pulling image: myAcrName.azurecr.io/mobile/signalr:c7aead0c46b66afc4131935efc7e6a51280dfb1a
2020-04-21 18:02:28.761 ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"manifest for myAcrName.azurecr.io/mobile/signalr:c7aead0c46b66afc4131935efc7e6a51280dfb1a not found: manifest unknown: manifest unknown"}
2020-04-21 18:02:28.761 ERROR - Pulling docker image myAcrName.azurecr.io/mobile/signalr:c7aead0c46b66afc4131935efc7e6a51280dfb1a failed:
2020-04-21 18:02:28.762 INFO - Pulling image from Docker hub: myAcrName.azurecr.io/mobile/signalr:c7aead0c46b66afc4131935efc7e6a51280dfb1a
2020-04-21 18:02:28.867 ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://myAcrName.azurecr.io/v2/mobile/signalr/manifests/c7aead0c46b66afc4131935efc7e6a51280dfb1a: unauthorized: authentication required"}
2020-04-21 18:02:28.870 ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
Very sophisticated error but the root cause is, that he is trying to get the image with non-existing tag, which is GIT COMMIT tag. And it suppose to get image by $(Build.BuildId) (this was my first attempt) or by $(Build.BuilNumber) (this was my second attempt)
Here is how this pipeline step (Deploy Azure App Service) looks like:
- task: AzureRmWebAppDeployment#4
displayName: 'Deploy Azure App Service'
inputs:
azureSubscription: mySubcsriptionARM
appType: webAppContainer
WebAppName: myProductsignalr
DockerNamespace: myAcrName.azurecr.io
DockerRepository: mobile/signalr
DockerImageTag: '$(Build.BuildNumber)'
When i go to Release pipeline logs as a "Deploy Azure App Service" log i see that
2020-04-21T18:41:01.6012767Z ##[section]Starting: Deploy Azure App Service
2020-04-21T18:41:01.6367124Z ==============================================================================
2020-04-21T18:41:01.6367787Z Task : Azure App Service deploy
2020-04-21T18:41:01.6368381Z Description : Deploy to Azure App Service a web, mobile, or API app using Docker, Java, .NET, .NET Core, Node.js, PHP, Python, or Ruby
2020-04-21T18:41:01.6368765Z Version : 4.163.5
2020-04-21T18:41:01.6369158Z Author : Microsoft Corporation
2020-04-21T18:41:01.6369603Z Help : https://aka.ms/azureappservicetroubleshooting
2020-04-21T18:41:01.6369976Z ==============================================================================
2020-04-21T18:41:03.8970184Z Got service connection details for Azure App Service:'myProductsignalr'
2020-04-21T18:41:04.5534864Z Trying to update App Service Configuration settings. Data: {"appCommandLine":null,"linuxFxVersion":"DOCKER|myAcrName.azurecr.io/mobile/signalr:1f283100"}
2020-04-21T18:41:05.5465725Z Updated App Service Configuration settings.
2020-04-21T18:41:05.5495890Z Trying to update App Service Application settings. Data: {"DOCKER_CUSTOM_IMAGE_NAME":"myAcrName.azurecr.io/mobile/signalr:1f283100"}
2020-04-21T18:41:06.2703349Z Updated App Service Application settings and Kudu Application settings.
2020-04-21T18:41:32.4715682Z Updated App Service Application settings and Kudu Application settings.
2020-04-21T18:41:33.4179962Z Successfully updated deployment History at https://myProductsignalr.scm.azurewebsites.net/api/deployments/111587494492765
2020-04-21T18:41:33.5945654Z App Service Application URL: http://myProductsignalr.azurewebsites.net
2020-04-21T18:41:33.6180118Z ##[section]Finishing: Deploy Azure App Service
What amazes me, that it is showing, that everything was ok - when it was far from "ok" :)
When i go to container settings after:
a) new code is published
b) build pipeline fires
c) release pipeline fires
i see it like this:
The tag is empty. If i would pick some tag manually:
And would choose: "SAVE" everything works correctly (SingalR is up and running correctly)
Clearly, I am missing something :/ Help me to see what;)
The root cause for me is that this fragment:
DockerImageTag: '$(Build.BuildNumber)'
should insert build number (as stated) and the info from container settings should be:
Pulling image: myAcrName.azurecr.io/mobile/signalr:20200421.09 (for BuildNumber 20200421.09) and it is inserting GIT COMMIT there as a tag and ends up with: Pulling image: myAcrName.azurecr.io/mobile/signalr:c7aead0c46b66afc4131935efc7e6a51280dfb1a Why o why?:)
[UPDATE 22.04 10:56]
I am posting build pipeline that i am using currently. I don't suppose it is important as it is working correctly, and the problem is more with deployment of correctly created docker image (on ACR), than with creating this image by the build pipeline. Nevertheless, here is the pipeline:
# Docker
# Build a Docker image
# https://learn.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- master
resources:
- repo: self
variables:
dockerRegistryServiceConnection: 'MyProductDockerACR'
imageRepository: 'mobile/signalr'
containerRegistry: 'myAcrName.azurecr.io'
dockerfilePath: '**/Dockerfile'
tag: '$(Build.BuildNumber)'
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker#2
displayName: Build and push image to container registry
inputs:
containerRegistry: $(dockerRegistryServiceConnection)
repository: $(imageRepository)
command: 'buildAndPush'
Dockerfile: $(dockerfilePath)
tags: |
$(tag)
I saw the release you are using is configured by UI. It's work logic much different with the one which configured by YAML.
In fact, here what you received just be the different performance produced while the running reason of the release are different.
I guess this release has the artifact source which targeting to Repos, right? You can confirm by checking its icon.
While the release source is coming from Repos, then the Build.BuildNumber would be the short part of the commit id(8 characters). And the Build.BuildId is the complete commit id.
If you want the release keep using the Build.Buildnumber value which the corresponding build(created/pushed image) was using, you must make sure the release source is targeting to this build. Also, this build need has artifacts generated. According to the YAML you shared, obviously, you haven't done that.
Only the release triggered by build along with artifact, then the Build.BuildNumber can be like 20200422.1 which the build was using.
So, please go your release definition, and re-configure its source to make sure it is coming from build artifact instead of repository.
Yes. You are right. You have mismatch in tags.
In Docker#2 task you can define tags:
steps:
- task: Docker#2
displayName: Login to ACR
inputs:
command: login
containerRegistry: devopsmanual-acr
- task: Docker#2
displayName: Build and Push
inputs:
repository: $(imageName)
command: buildAndPush
Dockerfile: build-docker-image/SampleAppForDocker/DOCKERFILE
tags: |
$(Build.BuildNumber)
- task: Docker#2
displayName: Logout of ACR
inputs:
command: logout
containerRegistry: devopsmanual-acr
Your definition should be pretty much like this one. Whre devopsmanual-acr is connection to your ACR.
.
I recently mad a blog post about creating docker images on Azure DevOps so maybe this will be also helpful for you.
If this won't be enough to solve your issue, please edit your question and show how you create and push your images.
I have a free account of gitlab.
I also have a company account (not sure which plan).
I have the exact same project, a wrapper on EventStore.
In the CI pipeline I want to spin up a container with event store so that I can run some integration tests against it.
This is my .gitlab-ci.yml that restores, compiles, runs tests and publishes nuget packages
#Stages
stages:
- ci
- pack
#Global variables
variables:
GITLAB_RUNNER_DOTNET_CORE: mcr.microsoft.com/dotnet/core/sdk:2.2
EVENT_STORE: eventstore/eventstore:release-5.0.2
NUGET_REPOSITORY: $NEXUS_NUGET_REPOSITORY
NUGET_API_KEY: $NEXUS_API_KEY
NUGET_FOLDER_NAME: nupkgs
#Docker image
image: $GITLAB_RUNNER_DOTNET_CORE
#Jobs
ci:
stage: ci
services:
- $EVENT_STORE
variables:
# event store service params testing with standard ports
EVENTSTORE_INT_TCP_PORT: "1113"
EVENTSTORE_EXT_TCP_PORT: "1113"
EVENTSTORE_INT_HTTP_PORT: "2113"
EVENTSTORE_EXT_HTTP_PORT: "2113"
EVENTSTORE_EXT_HTTP_PREFIXES: "http://*:2113/"
script:
- dotnet restore --no-cache --force
- dotnet build --configuration Release
- dotnet vstest test/*Tests/bin/Release/**/*Tests.dll
pack-beta-nuget:
stage: pack
script:
- export VERSION_SUFFIX=beta$CI_PIPELINE_ID
- dotnet pack *.sln --configuration Release --output $NUGET_FOLDER_NAME --version-suffix $VERSION_SUFFIX --include-source --include-symbols -p:SymbolPackageFormat=snupkg
- dotnet nuget push **/*.nupkg --api-key $NUGET_API_KEY --source $NUGET_REPOSITORY
except:
- master
pack-nuget:
stage: pack
script:
- dotnet restore
- dotnet pack *.sln --configuration Release --output $NUGET_FOLDER_NAME
- dotnet nuget push **/*.nupkg --api-key $NUGET_API_KEY --source $NUGET_REPOSITORY
only:
- master
As you can see, I spin up the event store container.
From my integration tests I try to connect to the container within the CI using the following connection string:
"ConnectTo=tcp://admin:changeit#127.0.0.1:1113; HeartBeatTimeout=500;";
With my work account it works fine, there is a container listening on 127.0.0.1 on port 1113 and I can connect to it using the above connection string.
With my free personal account it is unable to connect.
Why?
I suspect it has something to do with the way docker is available on both gitlab CI runners, but why is different?
And more important, how can I configure event store on my personal CI pipeline on my free account so that I can connect to it if the localhost is not a valid host Uri for whatever reason?
Well, you have not provided any details but it seems you're using the Docker executor. In that case, services are not available on localhost but only accessible as service aliases.
This is an extract from the working CI file:
test:
stage: test
script:
- dotnet test
variables:
ASPNETCORE_ENVIRONMENT: Testing
EVENTSTORE_EXT_HTTP_PORT: 2113
EVENTSTORE_EXT_TCP_PORT: 1113
EVENTSTORE_RUN_PROJECTIONS: all
EVENTSTORE_START_STANDARD_PROJECTIONS: "true"
EventStore__ConnectionString: ConnectTo=tcp://admin:changeit#eventstore:1113
services:
- name: eventstore/eventstore:latest
alias: eventstore
only:
refs:
- branches
- tags
For this to work, your appsettings.Testing.json file needs to point to ConnectTo=tcp://admin:changeit#eventstore:1113.
If you want to keep using the appsettings file with the configuration that points to localhost, you can override the setting using env variable in the CI file. Just remember to add environment variables as the configuration source. The code snippet above has such an override, matching our settings structure:
{
"EventStore": {
"ConnectionString": "ConnectTo=whatever"
}
}
If you ever decide using the Kubernetes executor, you will need to revert to using localhost, because Kubernetes executor creates one pod per build with multiple containers, including all service containers. There's an open issue to support service aliases with Kubernetes runners, I think it will be like 12.9 or 13, pretty soon. That being said, using service aliases is a safe, future proof way of making it all work.
P.S. Just noticed that your setup works with one account and doesn't work with another. My guess would be that you either use different executors (Docker doesn't work and Kubernetes works) or different GitLab versions (if the service alias issue has already been fixed).
I put the app.yaml under parse-community and exec gcloud app deploy.
I encountered a error same of this title.
this is my app.yaml
service: some-service
runtime: nodejs8
network:
name: some-network
I checked the corresponding data of stackdriver logging, but I did not see any errors that were particularly relevant.
But the service some-service exists in GAE services list on GCP Console.
I could access the service's endpoint url https://**appspot**.
I need to remove the error when deploying.
The app.yaml's network element is only available for the App Engine flexible environment (see doc here). As per your app.yaml file, you're trying to deploy your app to the Standard environment.
To deploy on flex, you should update your app.yaml like this:
service: some-service
runtime: nodejs8
env: flex
network:
name: some-network
I am deploying a new Node.js application to Google App Engine. I use Docker for local development so I have the following files in my root folder:
Dockerfile
.dockerignore
docker-compose.yml
docker-compose.debug.yml
When I run gcloud app deploy, I get the following error:
ERROR: (gcloud.app.deploy) There is a Dockerfile in the current directory, and the runtime field in /Users/Nag/Code/project/web-service/app.yaml is currently set to [runtime: nodejs]. To use your Dockerfile to build a custom runtime, set the runtime field to [runtime: custom]. To continue using the [nodejs] runtime, please remove the Dockerfile from this directory.
As per the Google App Engine app.yaml settings, I can include a skip_files key to ignore certain files. I included skip_files key in my app.yaml like this but it still throws the same error:
# [START app_yaml]
runtime: nodejs
env: flex
skip_files:
- /docker/i
automatic_scaling:
min_num_instances: 1
max_num_instances: 2
env_variables:
NODE_ENV: development
# [END app_yaml]
I would like to continue using the nodejs runtime when the application is running on App Engine and use Docker only on my local machine. I can't Git ignore the Docker files because other developers on the team need access to it in the repository. Can someone please help me understand why App Engine still recognizes my Docker files even though I am skipping them? Thanks.