TeamCity: push docker image to AWS ECR - amazon-web-services

Running TeamCity 2019.1.4 with one server and three separate agents. Both agents and the server are running in their respective server/agent containers in separate EC2 instances. I want the build artifact (docker image) to be pushed to the ECR. Permission is configured via IAM role. I am getting Unauthorized error when pushing/pulling. Manually pulling image from the agent EC2 host works. But manually pulling from within the agent EC2 container gives the same error. How do I configure the TeamCity agent container to identify itself as the host machine?
PS: An option I am trying to avoid is to run TeamCity agents in a classic mode (manual installation) which will most likely work.

Do the following:
in TeamCity project configuration, add ECR connection.
then, in the build configuration, add build feature, add "Docker Support".
make sure the choice "Log in to the Docker registry before the build"
is checked and you choose the ECR connection from the project
configuration.

Related

Deploy Django Code with Docker to AWS EC2 instance without ECS

Here is my setup.
My Django code is hosted on Github
I have docker setup in my EC2 Instance
My deployment process is manual. I have to run git pull, docker build and docker run on every single code change. I am using a dockerservice account to perform this step.
How do I automate step 3 with AWS code deploy or something similar.
Every example I am seeing on the internet involves ECS, Fargate which I am not ready to use yet
Check this out on how to Use Docker Images from a Private Registry (eg. dockerhub) for Your Build Environment
How to Use Docker Images from a Private Registry for Your Build Environment

Upload druid and superset image to ECS

I have created a docker image for DRUID and Superset, now I want to push these images to ECR. and start an ECS to run these containers. What I have done is I have created the images by running docker-compose up on my YML file. Now when I type docker image ls i can see multiple images running in them.
I have created an aws account and created a repository. They have provided the push command and I push the superset into the ECR for start. (Didn't push any dependancy)
I created a cluster in AWS, in one configuration step if provided custom port 8088. I don't know what and why they ask these port for.
Then I created a load balancer with the default configuration
After some time I could see the container status turned running
I navigated to the public ip i mentioned with port 8088 and could see superset running
Now I have two problems
It always shows login error in a superset
It stops automatically after some time and restarts after that and this cycle continues.
Should I create different ECR repos and push all the dependencies to ECR before creating a cluster in ECS?
For the service going up and down. Since you mentioned you have an LB associated with the service, you may have an issue with the health check configuration.
If the health check fails consecutively a number of times, ecs will kill it and re-start it.

How to deploy a spring boot application jar from Jenkins to an EC2 machine

I'm seeing so many different sources how to to achieve CI with Jenkins and EC2 and strangely none seem to fit my needs.
I have 2 EC2 ubuntu instances. One is empty and the other has Jenkins installed on it.
I want to perform a build on the Jenkins machine and copy the jar to the other ubuntu machine. Once the jar is there i want to run mvn spring-boot:run
That's is - a very simple flow which i can't find a good source to follow that doesn't include slaves, dockers etc..
AWS Code Deploy lets you use a Jenkins and deploy it on your EC2 instances.
Quick google search gave me this very detailed instruction on how to setup code pipeline with AWS Code Deploy.
The pipeline uses GitHub -> Jenkins -> EC2 flow, as you need it.
Set up jenkins to do a build then scp the artifact to the other machine
There's an answer here how to setup ssh keys for jenkins to publish via ssh about setting up the keys for ssh

How to push docker auto build image to AWS instance with a hook?

I have a Dockerhub account linked with Github which is auto build. With every action on Github , a build is started on dockerhub account. but now, I have to find a way through which AWS can listen the new build and take a pull of this build and run it.
I am new to docker skills, Please let me know if any one know the solution to this ?
You can use the Webhook feature in DockerHub to link with a CI/CD tool to trigger the docker pull in your EC2 instance. For example using Jenkins
Setup Jenkins in a EC2 instance or on-premise
Remote SSH to the EC2 instance using Jenkins Remote SSH plugin
Create a Build Job for Deployment
Inside the Job, add shell script code to pull the image from DockerHub.
To trigger the job, register a webhook linked with the Jenkins Job, inside DockerHub Webhooks section as a build trigger to invoke the webhook.

what triggers Elastic Beanstalk to pull in an updated Docker image

I have an Elastic Beanstalk application running and configured to serve a Docker container ("generic Docker" configuration) and linked to a private image on Docker Hub.
How can I prompt the Elastic Beanstalk application to download the latest version of the docker hub image after pushing up a new version with docker push?
Do I need to "restart the app server," "rebuild the environment," something else, or is "supposed" to pull it in automatically? Not seeing this addressed in the docs.
** EDIT **
To be clear, eb deploy does NOT pull in an updated Docker image, but it does push up the files from your application directory to your ec2 instances.
So, at the end of the day I'm probably not going to use docker push for deployments, but just to keep the image up to date in the case that you actually need to make ENVIRONMENT configuration changes, not code changes, or when bringing on a new developer, you can use docker pull.
Currently eb deploy my-environment-name is working great for Docker based Elastic Beanstalk deployments.
You just need to run command line: eb deploy. Here is a nice tutorial http://victorlin.me/posts/2014/11/26/running-docker-with-aws-elastic-beanstalk.