Compare commits

...

10 Commits

Author SHA1 Message Date
TP Honey
39d233b3d9
Update .drone.yml 2023-01-04 12:13:02 +00:00
TP Honey
d2b4c922fd
Update Dockerfile.windows.ltsc2022 2023-01-04 12:06:51 +00:00
TP Honey
c40d9ffccc
(maint) fix release for windows images (#49) 2023-01-04 11:54:02 +00:00
TP Honey
f03006262c
(maint) move to harness.drone.io (#48) 2023-01-04 10:25:17 +00:00
Julien Duchesne
8070857203
Add retries option (#43)
* Add `retries` option

It can be enabled this way:
```
clone:
  retries: 3
```
2021-11-23 10:23:52 +00:00
Brad Rydzewski
3ccd78325a revert to root due to npm issues 2021-05-14 09:09:58 -04:00
Brad Rydzewski
806bc25846 remove debug log entry 2021-05-06 14:40:28 -04:00
Brad Rydzewski
3d2cbbe9ba Merge remote-tracking branch 'origin/drone_non_root' into drone_non_root 2021-05-06 14:39:26 -04:00
Brad Rydzewski
f7b49aaf9e update readme and annotate code with change 2021-05-06 14:39:13 -04:00
Shubham Agrawal
be769618aa updated dockerfile for arm 2021-05-06 20:10:24 +05:30
14 changed files with 182 additions and 432 deletions

View File

@ -1,130 +0,0 @@
# this starlark script should be used to generate the .drone.yml
# configuration file.
def main(ctx):
# TODO consider running unit tests before building and
# publishing docker images.
before = {}
stages = [
linux('arm'),
linux('arm64'),
linux('amd64'),
windows('1903'),
windows('1809'),
]
after = manifest()
# the after stage should only execute after all previous
# stages complete. this builds the dependency graph.
for stage in stages:
after['depends_on'].append(stage['name'])
return stages + [ after ]
# create a pipeline stage responsible for building and
# publishing the Docker image on linux.
def linux(arch):
return {
'kind': 'pipeline',
'type': 'docker',
'name': 'linux-%s' % arch,
'platform': {
'os': 'linux',
'arch': arch,
},
'steps': [
{
'name': 'build',
'image': 'golang:1.10',
'commands': [
'cd posix',
'tar -xf fixtures.tar -C /',
'go test -v',
],
},
{
'name': 'publish',
'image': 'plugins/docker',
'settings': {
'auto_tag': 'true',
'auto_tag_suffix': 'linux-%s' % arch,
'dockerfile': 'docker/Dockerfile.linux.%s' % arch,
'password': {
'from_secret': 'docker_password',
},
'repo': 'drone/git',
'username': 'drone',
},
'when': {
'event': ['push', 'tag']
}
}
]
}
# create a pipeline stage responsible for building and
# publishing the Docker image on windows. The windows stage
# uses an ssh runner, as opposed to a docker runner.
def windows(version):
return {
'kind': 'pipeline',
'type': 'ssh',
'name': 'windows-%s-amd64' % version,
'platform': {
'os': 'windows'
},
'server': {
'host': { 'from_secret': 'windows_server_%s' % version },
'user': { 'from_secret': 'windows_username' },
'password': { 'from_secret': 'windows_password' },
},
'steps': [
{
'name': 'build',
'environment': {
'USERNAME': { 'from_secret': 'docker_username' },
'PASSWORD': { 'from_secret': 'docker_password' },
},
# TODO these commands build and publish the latest
# docker tag regardless of git tag.
'commands': [
'docker login -u $env:USERNAME -p $env:PASSWORD',
'docker build -f docker/Dockerfile.windows.%s -t drone/git:windows-%s-amd64 .' % (version, version),
'docker push drone/git:windows-%s-amd64' % version,
],
},
],
'trigger': {
'event': ['push']
}
}
# create a pipeline stage responsible for creating and
# publishing a docker manifest to the registry.
def manifest():
return {
'kind': 'pipeline',
'type': 'docker',
'name': 'manifest',
'steps': [
{
'name': 'manifest',
'image': 'plugins/manifest',
'settings': {
'auto_tag': 'true',
'username': 'drone',
'password': {
'from_secret': 'docker_password'
},
'spec': 'docker/manifest.tmpl',
'ignore_missing': 'true',
},
},
],
'depends_on': [],
'trigger': {
'event': ['push', 'tag']
}
}

View File

@ -1,226 +1,168 @@
---
# this file is automatically generated. DO NOT EDIT
kind: pipeline
type: docker
type: vm
name: linux-amd64
platform:
arch: amd64
os: linux
arch: amd64
pool:
use: ubuntu
steps:
- name: build
image: golang:1.10
commands:
- cd posix
- tar -xf fixtures.tar -C /
- go test -v
- name: build
image: golang:1.10
commands:
- cd posix
- tar -xf fixtures.tar -C /
- go test -v
- name: publish
image: plugins/docker:18
settings:
dockerfile: docker/Dockerfile.linux.amd64
repo: drone/git
auto_tag: "true"
auto_tag_suffix: linux-amd64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
- push
- tag
- name: publish
image: plugins/docker:18
settings:
dockerfile: docker/Dockerfile.linux.amd64
repo: drone/git
auto_tag: "true"
auto_tag_suffix: linux-amd64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
- push
- tag
---
kind: pipeline
type: docker
type: vm
name: linux-arm64
platform:
os: linux
arch: arm64
os: linux
pool:
use: ubuntu_arm64
steps:
- name: build
image: golang:1.10
commands:
- cd posix
- tar -xf fixtures.tar -C /
- go test -v
- name: build
image: golang:1.10
commands:
- cd posix
- tar -xf fixtures.tar -C /
- go test -v
- name: publish
image: plugins/docker:18
settings:
dockerfile: docker/Dockerfile.linux.arm64
repo: drone/git
auto_tag: "true"
auto_tag_suffix: linux-arm64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
- name: publish
image: plugins/docker:18
settings:
dockerfile: docker/Dockerfile.linux.arm64
repo: drone/git
auto_tag: "true"
auto_tag_suffix: linux-arm64
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
- push
- tag
---
kind: pipeline
type: vm
name: windows-1809
platform:
os: windows
arch: amd64
pool:
use: windows
steps:
- name: docker
image: plugins/docker
settings:
dockerfile: docker/Dockerfile.windows.1809
repo: drone/git
username:
from_secret: docker_username
password:
from_secret: docker_password
auto_tag: true
auto_tag_suffix: windows-1809-amd64
daemon_off: true
purge: false
trigger:
event:
- push
- tag
---
kind: pipeline
type: docker
name: linux-arm
type: vm
name: windows-ltsc2022
platform:
arch: arm
os: linux
os: windows
arch: amd64
pool:
use: windows-2022
steps:
- name: build
image: golang:1.10
commands:
- cd posix
- tar -xf fixtures.tar -C /
- go test -v
- name: docker
image: plugins/docker
settings:
dockerfile: docker/Dockerfile.windows.ltsc2022
repo: drone/git
username:
from_secret: docker_username
password:
from_secret: docker_password
auto_tag: true
auto_tag_suffix: windows-ltsc2022-amd64
daemon_off: true
purge: false
- name: publish
image: plugins/docker:18
settings:
dockerfile: docker/Dockerfile.linux.arm
repo: drone/git
auto_tag: "true"
auto_tag_suffix: linux-arm
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
event:
trigger:
event:
- push
- tag
---
kind: pipeline
type: ssh
name: windows-1909-amd64
platform:
os: windows
server:
host:
from_secret: windows_server_1909
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/Dockerfile.windows.1909 -t drone/git:windows-1909-amd64 .
- docker push drone/git:windows-1909-amd64
environment:
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger:
event:
- push
---
kind: pipeline
type: ssh
name: windows-1903-amd64
platform:
os: windows
server:
host:
from_secret: windows_server_1903
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/Dockerfile.windows.1903 -t drone/git:windows-1903-amd64 .
- docker push drone/git:windows-1903-amd64
environment:
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger:
event:
- push
---
kind: pipeline
type: ssh
name: windows-1809-amd64
platform:
os: windows
server:
host:
from_secret: windows_server_1809
password:
from_secret: windows_password
user:
from_secret: windows_username
steps:
- name: build
commands:
- docker login -u $env:USERNAME -p $env:PASSWORD
- docker build -f docker/Dockerfile.windows.1809 -t drone/git:windows-1809-amd64 .
- docker push drone/git:windows-1809-amd64
environment:
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
trigger:
event:
- push
---
kind: pipeline
type: docker
type: vm
name: manifest
platform:
os: linux
arch: amd64
pool:
use: ubuntu
steps:
- name: manifest
image: plugins/manifest
settings:
auto_tag: "true"
ignore_missing: "true"
spec: docker/manifest.tmpl
username:
from_secret: docker_username
password:
from_secret: docker_password
- name: manifest
image: plugins/manifest
settings:
auto_tag: "true"
ignore_missing: "true"
spec: docker/manifest.tmpl
username:
from_secret: docker_username
password:
from_secret: docker_password
trigger:
event:
- push
- tag
- push
- tag
depends_on:
- linux-amd64
- linux-arm64
- linux-arm
- windows-1909-amd64
- windows-1903-amd64
- windows-1809-amd64
- linux-amd64
- linux-arm64
- windows-1809
- windows-ltsc2022

View File

@ -16,6 +16,7 @@ Clone a commit:
```
docker run --rm \
-e DRONE_WORKSPACE=/drone \
-e DRONE_REMOTE_URL=https://github.com/drone/envsubst.git \
-e DRONE_BUILD_EVENT=push \
-e DRONE_COMMIT_SHA=15e3f9b7e16332eee3bbdff9ef31f95d23c5da2c \

View File

@ -2,9 +2,10 @@ FROM alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
ADD posix/* /usr/local/bin/
RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
USER drone:drone
RUN chmod -R 777 /home/drone
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
# USER drone:drone
# RUN chmod -R 777 /home/drone
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -1,5 +0,0 @@
FROM arm32v6/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -1,5 +0,0 @@
FROM arm32v6/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -1,5 +1,11 @@
FROM arm64v8/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
ADD posix/* /usr/local/bin/
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
# USER drone:drone
# RUN chmod -R 777 /home/drone
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -1,5 +0,0 @@
FROM arm32v6/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -1,5 +0,0 @@
FROM arm64v8/alpine:3.12
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl
ADD posix/* /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/clone"]

View File

@ -1,20 +0,0 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:1903 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git;
FROM mcr.microsoft.com/powershell:nanoserver-1903
COPY --from=git /git /git
ADD windows/* /bin/
# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]

View File

@ -1,20 +0,0 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:1909 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git;
FROM mcr.microsoft.com/powershell:nanoserver-1909
COPY --from=git /git /git
ADD windows/* /bin/
# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]

View File

@ -1,13 +1,13 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:1803 AS git
FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git;
FROM mcr.microsoft.com/powershell:nanoserver-1803
FROM mcr.microsoft.com/powershell:nanoserver-ltsc2022
COPY --from=git /git /git
ADD windows/* /bin/

View File

@ -17,24 +17,6 @@ manifests:
variant: v8
architecture: arm64
os: linux
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
variant: v7
architecture: arm
os: linux
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
platform:
variant: v6
architecture: arm
os: linux
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64
platform:
architecture: amd64
os: windows
version: 1803
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
platform:
@ -42,14 +24,8 @@ manifests:
os: windows
version: 1809
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1903-amd64
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64
platform:
architecture: amd64
os: windows
version: 1903
-
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1909-amd64
platform:
architecture: amd64
os: windows
version: 1909
version: ltsc2022

View File

@ -1,28 +1,25 @@
#!/bin/sh
if [[ ! -z "${DRONE_WORKSPACE}" ]]; then
if [[ -n "${CI}" ]]; then
sudo mkdir -p ${DRONE_WORKSPACE}
sudo chown drone:drone ${DRONE_WORKSPACE}
else
mkdir -p ${DRONE_WORKSPACE}
fi
if [[ -n "${DRONE_WORKSPACE}" ]]; then
# ensure the unprivileged drone user can write
# to the workspace. This is required because
# the workspace is a docker volume and is owned
# by root.
# sudo mkdir -p ${DRONE_WORKSPACE}
# sudo chown drone:drone ${DRONE_WORKSPACE}
# ensure the workspace is the current working
# directory. This should already be the case,
# but we cd just to be safe.
cd ${DRONE_WORKSPACE}
fi
# we default home directory to /home/drone
# force the home directory path.
if [ "$HOME" != "/home/drone" ]; then
export HOME=/home/drone
fi
# if the home directory does not exist it should
# be created.
if [ ! -d "${HOME}" ]; then
echo "HOME directory does not exist; creating ${HOME}"
mkdir -p ${HOME}
fi
# if [ "$HOME" != "/home/drone" ]; then
# echo "[DEBUG] setting default home directory"
# export HOME=/home/drone
# fi
# if the netrc enviornment variables exist, write
# the netrc file.
@ -90,14 +87,31 @@ case $DRONE_COMMIT_REF in
refs/merge-requests/* ) CLONE_TYPE=pull_request ;;
esac
git_clone_retry(){
retries="${PLUGIN_RETRIES:-0}"
if [ -n "${retries##*[0-9]*}" ] || [ "${retries}" -lt 0 ]; then
echo "PLUGIN_RETRIES defined but is not a number: ${retries}" >&2
exit 1
fi
echo "Cloning with ${retries} retries"
n=0
until [ "$n" -gt "${retries}" ]; do
$1 && return
n=$((n+1))
done
exit 1
}
case $CLONE_TYPE in
pull_request)
clone-pull-request
git_clone_retry clone-pull-request
;;
tag)
clone-tag
git_clone_retry clone-tag
;;
*)
clone-commit
git_clone_retry clone-commit
;;
esac
esac