-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build and push docker image to containers registry (#2817)
- Loading branch information
1 parent
8c32b42
commit 3a1c8bb
Showing
10 changed files
with
291 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Create container based on Ubuntu-22.04 Jammy Jellyfish image | ||
FROM mcr.microsoft.com/mirror/docker/library/ubuntu:22.04 | ||
|
||
# Copy azcopy binary to executable path | ||
COPY ./azcopy /usr/local/bin/ | ||
|
||
# Make azcopy executable | ||
RUN chmod +x /usr/local/bin/azcopy | ||
|
||
# Install dependencies | ||
RUN \ | ||
apt update && \ | ||
apt-get install -y ca-certificates | ||
|
||
WORKDIR /azcopy | ||
CMD [ "azcopy" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Create container based on Ubuntu-22.04 Jammy Jellyfish image | ||
FROM --platform=linux/arm64 mcr.microsoft.com/mirror/docker/library/ubuntu:22.04 | ||
|
||
# Copy azcopy binary to executable path | ||
COPY ./azcopy /usr/local/bin/ | ||
|
||
# Make azcopy executable | ||
RUN chmod +x /usr/local/bin/azcopy | ||
|
||
# Install dependencies | ||
RUN \ | ||
apt update && \ | ||
apt-get install -y ca-certificates | ||
|
||
WORKDIR /azcopy | ||
CMD [ "azcopy" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Create container based on Ubuntu-22.04 Jammy Jellyfish image | ||
FROM mcr.microsoft.com/cbl-mariner/base/core:2.0 | ||
|
||
# Install dependencies | ||
RUN tdnf update -y | ||
RUN tdnf install -y ca-certificates | ||
|
||
# Copy azcopy binary to executable path | ||
COPY ./azcopy /usr/local/bin/ | ||
|
||
# Make azcopy executable | ||
RUN chmod +x /usr/local/bin/azcopy | ||
|
||
WORKDIR /azcopy | ||
CMD [ "azcopy" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Steps to Pull an Image from Azure Container Registry: | ||
|
||
# 1. Login to Azure | ||
|
||
az login | ||
|
||
# 2. Login to the Azure Container Registry | ||
|
||
az acr login --name azcopycontainers | ||
|
||
# 3. List the Images in Your ACR | ||
|
||
az acr repository list --name azcopycontainers --output table | ||
|
||
# 4. Pull the Image | ||
|
||
docker pull azcopycontainers.azurecr.io/<imagename>:<tag> | ||
|
||
# 5. Run the Image | ||
|
||
docker run --rm -it -v /local/path/to/mount:/azcopy azcopycontainers.azurecr.io/<imagename>:<tag> azcopy copy <source> <destination> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
echo "Using Go - $(go version)" | ||
rm -rf azcopy | ||
rm -rf azure-storage-azcopy | ||
go build -o azcopy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Build azcopy binary | ||
./dockerinstall.sh | ||
./buildcontainer.sh Dockerfile ubuntu-x86_64 | ||
|
||
# Fetch the version of azcopy and extract the version number | ||
azcopy_version=$(../azcopy --version | awk '{print $3}') | ||
|
||
# Construct the Docker image tag using the fetched version | ||
docker_image_tag="azure-azcopy-ubuntu-x86_64.$azcopy_version" | ||
|
||
# If build was successful then launch a container instance | ||
status=`docker images | grep $docker_image_tag` | ||
|
||
curr_dir=`pwd` | ||
mkdir -p $curr_dir/azcopy | ||
echo "Hello World" > $curr_dir/azcopy/hello.txt | ||
|
||
if [ $? = 0 ]; then | ||
echo " **** Build successful, running container now ******" | ||
|
||
# Debug: Check the tag being used | ||
echo "Using Docker image: $docker_image_tag" | ||
|
||
docker run -it --rm \ | ||
-v $curr_dir/azcopy:/azcopy \ | ||
$docker_image_tag azcopy --help | ||
else | ||
echo "Failed to build docker image" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
# Build azcopy binary | ||
cd .. | ||
echo "Building azcopy" | ||
./docker/build.sh | ||
ls -l azcopy | ||
|
||
ver=`./azcopy --version | cut -d " " -f 3` | ||
tag="azure-azcopy-$2.$ver" | ||
|
||
# Cleanup older container image from docker | ||
sudo docker image rm $tag -f | ||
|
||
# Build new container image using current code | ||
echo "Build container for azcopy" | ||
cd - | ||
cp ../azcopy ./azcopy | ||
sudo docker build -t $tag -f $1 . | ||
|
||
# List all images to verify if new image is created | ||
sudo docker images | ||
|
||
# Image build is executed so we can clean up temp executable from here | ||
rm -rf ./azcopy | ||
|
||
# If build was successful then launch a container instance | ||
status=`sudo docker images | grep $tag` | ||
echo $status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Cleanup old installation | ||
sudo apt remove docker-desktop | ||
rm -r $HOME/.docker/desktop | ||
sudo rm /usr/local/bin/com.docker.cli | ||
sudo apt purge docker-desktop | ||
sudo apt-get update | ||
|
||
# Install certificates and pre-requisites | ||
sudo apt-get install ca-certificates curl gnupg lsb-release -y | ||
sudo mkdir -p /etc/apt/keyrings | ||
|
||
# Create keyring for docker | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg -y | ||
|
||
# Create file for installation | ||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
|
||
# Install docker | ||
sudo apt-get update | ||
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y | ||
sudo apt-get update | ||
|
||
# Resolve permission issues to connect to docker socket | ||
sudo groupadd docker | ||
sudo usermod -aG docker $USER | ||
sudo chown root:docker /var/run/docker.sock | ||
|
||
# Create the .docker directory if it doesn't exist | ||
mkdir -p $HOME/.docker | ||
sudo chown "$USER":"$USER" /home/"$USER"/.docker -R | ||
sudo chmod g+rwx "$HOME/.docker" -R | ||
|
||
# Delete old azcopy image | ||
docker rmi `docker images | grep azcopy | cut -d " " -f1` | ||
|
||
# Remove existing images | ||
docker system prune -f | ||
|
||
# Start docker service | ||
sudo service docker start | ||
|
||
# List docker container images | ||
docker images ls | ||
|
||
# List docker instances running | ||
docker container ls | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
ver=`../azcopy --version | cut -d " " -f 3` | ||
image="azure-azcopy-$3.$ver" | ||
|
||
sudo docker login azcopycontainers.azurecr.io --username $1 --password $2 | ||
|
||
# Publish Ubn-22 container image | ||
sudo docker tag $image:latest azcopycontainers.azurecr.io/$image | ||
sudo docker push azcopycontainers.azurecr.io/$image | ||
|
||
sudo docker logout azcopycontainers.azurecr.io | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters