I'm actually setting up a devops environement using Github Actions and Microsoft Azure services. One of the steps i use in my pipeline is building a Docker image and pushing it to Azure Container Registry (ACR). To do that, i'm using the official action.
The problem is that when my Dockerfile is built , the server cannot find the path for the files i used in it.
To make it work, i tried to change the folder i passed to the action but with no result. Despite my Dockerfile is at the root of my project ( the default value in the action ), i get an error even when i'm explicitely giving the path.
I understood that the context of the server in which it runs is way different than mine. Knowing that in my workflow i build the project (to generate the JAR file) before trying to build the Docker image so the JAR file exists on the server which runs the workflow (Github server). I tried to debug the Build action, and the line which fails is 26 : az acr build ..., i'm actually 99% sure that all arguments are correct, but i still get the context error.
I tried to understand by myself and searched in the Azure CLI documentation but couldn't find the information. So now the question i'm asking myself is : does the az acr build run locally on the shell which called it (check scenario 1 image) ? or on an azure server which would explains why the server cannot find the JAR file (scenario 2) ?
And if it is scenario 2, is there a way to make pass the JAR file to az acr build and influence the server context ? Or should i ignore the official action and rewrite an action by myself which build the image locally not using the az acr build command ?
My Dockerfile (Spring Boot project) :
FROM openjdk:11
COPY target/devOps-0.0.1-SNAPSHOT.jar devOps-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java", "-jar", "/devOps-0.0.1-SNAPSHOT.jar"]
The error i get :
Step 2/3 : COPY target/devOps-0.0.1-SNAPSHOT.jar devOps-0.0.1-SNAPSHOT.jar
COPY failed: file not found in build context or excluded by .dockerignore: stat target/devOps-0.0.1-SNAPSHOT.jar: file does not exist
2022/11/02 08:16:14 Container failed during run: build. No retries remaining.
failed to run step ID: build: exit status 1
Scenario 1 :
Scenario 2 :
Related
I want to deploy a laravel site using elastic beanstalk.
I'm using pipelines pulling from a BitBucket repository.
After I created my EB application and environment, I changed the document-root to /web/public because the laravel-root is under the '[repo-root]/web' directory.
The deployment is failing:
2023/02/12 01:40:11 [error] 3857#3857: *109 "/var/www/html/var/www/html/web/public/index.php" is not found (2: No such file or directory), client: ..., server: , request: "GET / HTTP/1.1", host: "..."
A similar project where the laravel-root === 'repo-root' and document-root: public works, but this is not ideal.
How can I configure the pipeline or EB to use the '[repo-root]/web' as the document-root?
I've unsuccessfully tried various values for the document-root, but nothing seems to work.
In another forum, someone suggested changing the pipeline to return the laravel-root as an artifact, but I'm not sure how to do this. Seems like it is stored as a zip under S3 and if I change to Full Clone I get an invalid-structure error related to code build. I don't know what that means since I'm not using code build.
TIA
While I'm sure there are a number of ways to solve this, what worked for me was using CodeBuild to pull the code from the repo and a buildspec.yml file to create a zip of just the directory required for deployment.
buildspec.yml
version: 0.2
phases:
pre_build:
commands:
- cd web
- zip -r ../web.zip ./*
artifacts:
files:
- web.zip
Still under CodeBuild, I configured the Artifacts to output to an S3 bucket. Then I created a Code Pipeline with a Source stage that pulls the zip from the build bucket and a Deploy stage that sends the source artifact to Elastic Beanstalk (provider). When setting up the pipeline, it seems to want you to have a 'Build' stage between Source and Deploy, but I deleted this.
It looks like you can also leverage artifact handling and let CodeBuild do the packaging (zipping). I haven't tested this. https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.artifacts.base-directory
...
artifacts:
files:
- '**/*'
base-directory: 'my-build*'
As far as the weird pathing issue in the original post, I think there was some sort of EB config cache issue/corruption. When I rebuilt the environment, that error was gone.
I am trying to install a sample application using the git option in OpenShift 4.7.2 (CodeReady containers 1.24) and I keep getting the below error while openshift tries to build the image to be deployed.
Failed to pull image
"image-registry.openshift-image-registry.svc:5000/employee-ecosys/person-service:latest": rpc error:
code = Unknown
desc = Error reading manifest latest in image-registry.openshift-image-registry.svc:5000/employee-ecosys/person-service:
manifest unknown: manifest unknown
The application person-service is a simple crud application build using spring-boot and uses in-memory h2 as its database. Github repo is here
Some checks to perform:
Are the image registry pods running?
oc get pods -n openshift-image-registry
Is your specific image created?
oc get images | grep "person-service"
Do you get any images?
oc get images
"latest" is kind of a special tag. You should never manually tag an image as "latest". Openshift will consider the "latest" tag to be the newest image, regardless of what tag it has.
I am not familiar with the git deploy method. I have personally very little experience with any s2i builds. I normally use a git repo for the openshift/kubernetes resources and a git repo for the code (they can be the same but separated in the tree by folder structure) and use a pipeline or manually build the image and push it to a registry somewhere and then let openshift pull it from there.
How can I create and use the imagestream of jboss webserver in openshift origin ?
Image yaml available in this link. I see that it is automatically built with openshift enterprise version (link) . but why not in origin ?
Thanks.
I expected it to pull itself the image during build but did not happen.
D:\docker\apps>oc new-build --image-stream=jboss-webserver31-tomcat7-openshift:1.1 --name=newapp --binary=true
warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
error: unable to locate any images in image streams with name "jboss-webserver31-tomcat7-openshift:1.1"
The 'oc new-build' command will match arguments to the following types:
1. Images tagged into image streams in the current project or the 'openshift' project
- if you don't specify a tag, we'll add ':latest'
2. Images in the Docker Hub, on remote registries, or on the local Docker engine
3. Git repository URLs or local paths that point to Git repositories
--allow-missing-images can be used to force the use of an image that was not matched
See 'oc new-build -h' for examples.
So I tried to create the import yaml in webconsole but got below error with yaml.
Failed to process the resource.
Resource is missing kind field.
Got it. Apparently one has to be logged in redhat
oc import-image my-jboss-webserver-3/webserver31-tomcat7-openshift --from=registry.access.redhat.com/jboss-webserver-3/webserver31-tomcat7-openshift --confirm
Using this tutorial for using private Node.js repo from BitBucket in OpenShift, in last command getting an error, why?
Kukodas-MBP:~ kukodajanos$ ./oc new-app httpd~git#bitbucket.org:j4nos/nodejs.git --name mysite
error: Errors occurred while determining argument types:
httpd~git#bitbucket.org:j4nos/nodejs.git as a local directory pointing to a Git repository: stat httpd~git#bitbucket.org:j4nos/nodejs.git: no such file or directory
Errors occurred during resource creation:
error: the image match "httpd" for source repository "git#bitbucket.org:j4nos/nodejs.git" does not appear to be a source-to-image builder.
- to attempt to use this image as a source builder, pass "--strategy=source"
- to use it as a base image for a Docker build, pass "--strategy=docker"
Changed httpd to nodejs, I am using for repo name, and so it works:
Kukodas-MBP:~ kukodajanos$ ./oc new-app nodejs~git#bitbucket.org:j4nos/nodejs.git --name mysite
--> Found image cd02d02 (3 weeks old) in image stream "openshift/nodejs" under tag "6" for "nodejs"
Node.js 6
---------
Node.js 6 available as docker container is a base platform for building and running various Node.js 6 applications and frameworks. Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
Tags: builder, nodejs, nodejs6
* A source build using source code from ssh://git#bitbucket.org/j4nos/nodejs.git will be created
* The resulting image will be pushed to image stream "mysite:latest"
* Use 'start-build' to trigger a new build
* This image will be deployed in deployment config "mysite"
* Port 8080/tcp will be load balanced by service "mysite"
* Other containers can access this service through the hostname "mysite"
--> Creating resources ...
imagestream "mysite" created
buildconfig "mysite" created
deploymentconfig "mysite" created
I am trying to configure continuous deployment to a test server on Azure. The app is an ASP.Net application, but in this case that shouldn't really matter.
My build process (team city) produces a folder that has everything needed to deploy (minus some connection string info). If you point IIS at that directory it works great. If you FTP that directory up to Azure it also works.
I am tracking each of these builds in git and pushing them up to Github. So I am trying to use Azure deployment option to deploy from github. Everything is in git. The /bin folder included.
Kudu shouldn't need to do anything but a pull from git and copy all the files to wwwroot.
So I've set my .deployment file to be this:
[config]
project = .
Every time I do that, though, the deployment gives me the message:
Using cached version of deployment script (command: 'azure -y --no-dot-deployment -r "D:\home\site\repository" -o "D:\home\site\deployments\tools" --aspWAP "D:\home\site\repository\MyProj.csproj" --no-solution').
And it runs some generic autogenerated deploy.cmd.
If I delete the deploy.cmd from the cache, it regenerates some generic one.
And, most importantly, in doing all this, the WRONG ASSEMBLY IS BEING DEPLOYED!!
My app depends on System.Web.Helpers.dll. The correct version of this DLL is in github. I've verified this multiple times.
Kudu, however, is grabbing an OLDER one from NuGet and deploying that. And, of course, I get the dreaded YSOD error about not being able to load that file.
What do I need to do to make Kudu just copy the files from my github repository to wwwroot and nothing else?
I wound up getting it to deploy by hand editing the autogenerated deploy.cmd file that lives at \home\site\deployments\tools\deploy.cmd in kudu.
I commented out the 2 autogenerated lines of:
:: 1. Restore NuGet packages
:: 2. Build to the temporary path
(commented out all the code underneath them, too)
And then hand-edited the 3rd section to run kudu sync from the DEPLOYMENT_SOURCE instead of the temp file like this:
:: 3. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_SOURCE%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
IF !ERRORLEVEL! NEQ 0 goto error
)