From 29b08857bf9e1983f7b9f46a4cc073f34010eac9 Mon Sep 17 00:00:00 2001 From: alex-codefresh Date: Thu, 12 Apr 2018 07:20:16 +0000 Subject: [PATCH 01/11] Add Dockerfile, modify the start script --- Dockerfile.windows | 28 ++++++++++++++++++++++++++++ start.sh | 7 ++++--- 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 Dockerfile.windows diff --git a/Dockerfile.windows b/Dockerfile.windows new file mode 100644 index 0000000..744d53a --- /dev/null +++ b/Dockerfile.windows @@ -0,0 +1,28 @@ +FROM microsoft/windowsservercore:1709 + +COPY .ssh/ C:/cygwin64/.ssh/ +COPY ./start.sh C:/cygwin64/start.sh + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] + +RUN $url = 'https://cygwin.com/setup-x86_64.exe'; \ + Write-Host ('Downloading {0} ...' -f $url); \ + Invoke-WebRequest -Uri $url -OutFile 'C:/setup-x86_64.exe'; \ + \ + Write-Host 'Installing ...'; \ + New-Item -ItemType directory -Path 'C:/tmp'; \ + Start-Process "C:/setup-x86_64.exe" -NoNewWindow -Wait -PassThru -ArgumentList @('-q','-v','-n','-B','-R','C:/cygwin64','-l','C:/tmp','-s','http://mirror.pkill.info/cygwin/','-P','default,git,openssl'); \ + \ + Write-Host 'Removing ...'; \ + Remove-Item -Path 'C:/tmp' -Force -Recurse -ErrorAction Ignore; \ + \ + Write-Host 'Verifying install ...'; \ + Start-Process "C:/cygwin64/bin/cygcheck.exe" -NoNewWindow -Wait -PassThru -ArgumentList @('-c'); \ + \ + Write-Host 'Complete.'; + +SHELL ["C:/cygwin64/bin/sh", "-l", "-c"] + +RUN 'sed -i "s/\r$//" /start.sh' + +CMD '/start.sh' \ No newline at end of file diff --git a/start.sh b/start.sh index c20879f..10de3db 100755 --- a/start.sh +++ b/start.sh @@ -36,12 +36,13 @@ set -e [ -z "$REVISION" ] && (echo "missing REVISION var" | tee /dev/stderr) && exit 1 -echo "$PRIVATE_KEY" > /root/.ssh/codefresh -chmod 700 ~/.ssh/ -chmod 600 ~/.ssh/* +echo "$PRIVATE_KEY" | tr -d '\n' > /.ssh/codefresh +chmod 700 /.ssh/ +chmod 600 /.ssh/* cd $WORKING_DIRECTORY +HOME=/home git config --global advice.detachedhead false git config --global credential.helper "/bin/sh -c 'echo username=$USERNAME; echo password=$PASSWORD'" From fec379a3771c617819be5db068f4e223a011149c Mon Sep 17 00:00:00 2001 From: alex-codefresh Date: Thu, 24 May 2018 12:05:40 +0000 Subject: [PATCH 02/11] Fix Dockerfile.windows --- Dockerfile.windows | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile.windows b/Dockerfile.windows index 744d53a..0264923 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -1,8 +1,5 @@ FROM microsoft/windowsservercore:1709 -COPY .ssh/ C:/cygwin64/.ssh/ -COPY ./start.sh C:/cygwin64/start.sh - SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] RUN $url = 'https://cygwin.com/setup-x86_64.exe'; \ @@ -21,8 +18,15 @@ RUN $url = 'https://cygwin.com/setup-x86_64.exe'; \ \ Write-Host 'Complete.'; +RUN $ACL=Get-Acl -Path 'C:\'; \ + Set-Acl -Path 'C:\cygwin64\' -AclObject $ACL + SHELL ["C:/cygwin64/bin/sh", "-l", "-c"] +COPY .ssh/ C:/cygwin64/.ssh/ +COPY ./start.sh C:/cygwin64/start.sh + RUN 'sed -i "s/\r$//" /start.sh' -CMD '/start.sh' \ No newline at end of file +ENTRYPOINT ["C:/cygwin64/bin/sh", "-l", "-c"] +CMD ["/start.sh"] \ No newline at end of file From 6168d25dcb2e83ad144fbae299e4041043b49e49 Mon Sep 17 00:00:00 2001 From: alex-codefresh Date: Wed, 18 Jul 2018 09:45:13 +0000 Subject: [PATCH 03/11] Windows Server v1803 --- Dockerfile.windows | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.windows b/Dockerfile.windows index 0264923..83158fa 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -1,4 +1,4 @@ -FROM microsoft/windowsservercore:1709 +FROM microsoft/windowsservercore:1803 SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] From ddfb64a9c5a4f721c8304a2ef6b60ab1f2581543 Mon Sep 17 00:00:00 2001 From: alex-codefresh Date: Tue, 11 Dec 2018 13:57:13 +0000 Subject: [PATCH 04/11] Windows 1809 --- Dockerfile.windows | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.windows b/Dockerfile.windows index 83158fa..a0b3ed4 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -1,4 +1,4 @@ -FROM microsoft/windowsservercore:1803 +FROM mcr.microsoft.com/windows/servercore:1809 SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] From 25a0fee4a07c2a472a10796623e5a9361a461c15 Mon Sep 17 00:00:00 2001 From: alex-codefresh Date: Thu, 28 Mar 2019 14:47:18 +0300 Subject: [PATCH 05/11] Merge latest script changes from master --- start.sh | 55 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/start.sh b/start.sh index 10de3db..d6c4c95 100755 --- a/start.sh +++ b/start.sh @@ -20,7 +20,7 @@ git_retry () { if [[ $EXIT_CODE == 0 ]]; then break elif [[ $EXIT_CODE == "$RETRY_ON_SIGNAL" ]]; then - echo "$COMMAND failed with Exit Code $EXIT_CODE - try $TRY_NUM " + echo "Failed with Exit Code $EXIT_CODE - try $TRY_NUM " TRY_NUM=$(( ${TRY_NUM} + 1 )) sleep $RETRY_WAIT else @@ -40,6 +40,7 @@ echo "$PRIVATE_KEY" | tr -d '\n' > /.ssh/codefresh chmod 700 /.ssh/ chmod 600 /.ssh/* +mkdir -p "$WORKING_DIRECTORY" cd $WORKING_DIRECTORY HOME=/home @@ -53,29 +54,45 @@ if [ -d "$CLONE_DIR" ]; then echo "Preparing to update $REPO" cd $CLONE_DIR - # Reset the remote URL because the embedded user token may have changed - git remote set-url origin $REPO + # Make sure the CLONE_DIR folder is a git folder + if git status &> /dev/null ; then + # Reset the remote URL because the embedded user token may have changed + git remote set-url origin $REPO - echo "Cleaning up the working directory" - git reset -q --hard - git clean -df - git gc - git_retry git remote prune origin + echo "Cleaning up the working directory" + git reset -q --hard + git clean -df + git gc --force + git_retry git remote prune origin + git_retry git fetch origin --tags --prune "+refs/tags/*:refs/tags/*" - echo "Fetching the updates from origin" - git_retry git fetch --tags + echo "Fetching the updates from origin" + git_retry git fetch --tags - if [ -n "$REVISION" ]; then + if [ -n "$REVISION" ]; then - echo "Updating $REPO to revision $REVISION" - git checkout $REVISION + echo "Updating $REPO to revision $REVISION" + git checkout $REVISION - CURRENT_BRANCH="`git branch 2>/dev/null | grep '^*' | cut -d' ' -f2-`" + CURRENT_BRANCH="`git branch 2>/dev/null | grep '^*' | cut -d' ' -f2-`" - # If the revision is identical to the current branch we can rebase it with the latest changes. This isn't needed when running detached - if [ "$REVISION" == "$CURRENT_BRANCH" ]; then - echo 'Rebasing current branch $REVISION to latest changes...' - git rebase + # If the revision is identical to the current branch we can rebase it with the latest changes. This isn't needed when running detached + if [ "$REVISION" == "$CURRENT_BRANCH" ]; then + echo 'Rebasing current branch $REVISION to latest changes...' + git rebase + fi + fi + else + # The folder already exists but it is not a git repository + # Clean folder and clone a fresh copy on current directory + cd .. + rm -rf $CLONE_DIR + echo "cloning $REPO" + git_retry git clone $REPO $CLONE_DIR + cd $CLONE_DIR + + if [ -n "$REVISION" ]; then + git checkout $REVISION fi fi else @@ -88,4 +105,4 @@ else if [ -n "$REVISION" ]; then git checkout $REVISION fi -fi +fi \ No newline at end of file From c8cbbef4ec490b2e85311a87d6b89b708a03f294 Mon Sep 17 00:00:00 2001 From: alex-codefresh Date: Sat, 30 Mar 2019 14:26:02 +0300 Subject: [PATCH 06/11] Remove the unnecessary commands, which affect performance badly --- start.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/start.sh b/start.sh index d6c4c95..5e9bebd 100755 --- a/start.sh +++ b/start.sh @@ -62,9 +62,7 @@ if [ -d "$CLONE_DIR" ]; then echo "Cleaning up the working directory" git reset -q --hard git clean -df - git gc --force git_retry git remote prune origin - git_retry git fetch origin --tags --prune "+refs/tags/*:refs/tags/*" echo "Fetching the updates from origin" git_retry git fetch --tags From 7689ca4968f6d7e9cdb40e16d41c301f26ce1980 Mon Sep 17 00:00:00 2001 From: alex-codefresh Date: Wed, 3 Apr 2019 09:37:27 +0000 Subject: [PATCH 07/11] Add codefresh label to Dockerfile --- Dockerfile.windows | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile.windows b/Dockerfile.windows index a0b3ed4..65ac544 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -28,5 +28,7 @@ COPY ./start.sh C:/cygwin64/start.sh RUN 'sed -i "s/\r$//" /start.sh' +LABEL owner="codefresh.io" + ENTRYPOINT ["C:/cygwin64/bin/sh", "-l", "-c"] CMD ["/start.sh"] \ No newline at end of file From 84e99e339d5e3ba17c34ca0ecc89f5ddd0a5129b Mon Sep 17 00:00:00 2001 From: alex-codefresh Date: Sat, 8 Jun 2019 11:29:47 +0300 Subject: [PATCH 08/11] Fix workdir for merged engine --- start.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/start.sh b/start.sh index 5e9bebd..217bc31 100755 --- a/start.sh +++ b/start.sh @@ -34,6 +34,8 @@ git_retry () { trap exit_trap EXIT set -e +WORKING_DIRECTORY="C:${WORKING_DIRECTORY}" + [ -z "$REVISION" ] && (echo "missing REVISION var" | tee /dev/stderr) && exit 1 echo "$PRIVATE_KEY" | tr -d '\n' > /.ssh/codefresh From ce30d048964be30ef5e81c8c1584392769c66745 Mon Sep 17 00:00:00 2001 From: alex-codefresh Date: Wed, 6 May 2020 16:09:40 +0300 Subject: [PATCH 09/11] Update Dockerfile for windows --- Dockerfile.windows | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.windows b/Dockerfile.windows index 65ac544..4222d9a 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/windows/servercore:1809 +FROM mcr.microsoft.com/windows/servercore:1909 SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] @@ -8,7 +8,7 @@ RUN $url = 'https://cygwin.com/setup-x86_64.exe'; \ \ Write-Host 'Installing ...'; \ New-Item -ItemType directory -Path 'C:/tmp'; \ - Start-Process "C:/setup-x86_64.exe" -NoNewWindow -Wait -PassThru -ArgumentList @('-q','-v','-n','-B','-R','C:/cygwin64','-l','C:/tmp','-s','http://mirror.pkill.info/cygwin/','-P','default,git,openssl'); \ + Start-Process "C:/setup-x86_64.exe" -NoNewWindow -Wait -PassThru -ArgumentList @('-q','-v','-n','-B','-R','C:/cygwin64','-l','C:/tmp','-s','https://mirrors.sonic.net/cygwin/','-P','default,git,openssl'); \ \ Write-Host 'Removing ...'; \ Remove-Item -Path 'C:/tmp' -Force -Recurse -ErrorAction Ignore; \ From f96d205f9394d5a842be1eff76bec2edc0e39889 Mon Sep 17 00:00:00 2001 From: alex-codefresh Date: Fri, 15 Jan 2021 16:28:19 +0300 Subject: [PATCH 10/11] Use pinned working version of cygwin --- Dockerfile.windows | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.windows b/Dockerfile.windows index 4222d9a..d951aa8 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -8,7 +8,7 @@ RUN $url = 'https://cygwin.com/setup-x86_64.exe'; \ \ Write-Host 'Installing ...'; \ New-Item -ItemType directory -Path 'C:/tmp'; \ - Start-Process "C:/setup-x86_64.exe" -NoNewWindow -Wait -PassThru -ArgumentList @('-q','-v','-n','-B','-R','C:/cygwin64','-l','C:/tmp','-s','https://mirrors.sonic.net/cygwin/','-P','default,git,openssl'); \ + Start-Process "C:/setup-x86_64.exe" -NoNewWindow -Wait -PassThru -ArgumentList @('-q','-v','-n','-B','-R','C:/cygwin64','-l','C:/tmp','-s','http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/64bit/2019/03/06/161558','-X','-P','default,git,openssl'); \ \ Write-Host 'Removing ...'; \ Remove-Item -Path 'C:/tmp' -Force -Recurse -ErrorAction Ignore; \ From ab974fc0756efe4e0747fdfe4be7f448c205710b Mon Sep 17 00:00:00 2001 From: alex-codefresh Date: Sat, 16 Jan 2021 10:43:59 +0300 Subject: [PATCH 11/11] Use OS_RELEASE build arg --- Dockerfile.windows | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile.windows b/Dockerfile.windows index d951aa8..cc55b70 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -1,4 +1,6 @@ -FROM mcr.microsoft.com/windows/servercore:1909 +ARG OS_RELEASE + +FROM mcr.microsoft.com/windows/servercore:${OS_RELEASE} SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]