agola run: build images and push them when on a v.* tag
This commit is contained in:
parent
c54d2de4d1
commit
6dc7307dfd
|
@ -36,7 +36,7 @@ local task_build_go(version, arch) = {
|
||||||
{ type: 'run', command: 'golangci-lint run --deadline 5m' },
|
{ type: 'run', command: 'golangci-lint run --deadline 5m' },
|
||||||
{ type: 'run', name: 'build docker/k8s drivers tests binary', command: 'CGO_ENABLED=0 go test -c ./internal/services/executor/driver -o ./bin/docker-tests' },
|
{ type: 'run', name: 'build docker/k8s drivers tests binary', command: 'CGO_ENABLED=0 go test -c ./internal/services/executor/driver -o ./bin/docker-tests' },
|
||||||
{ type: 'run', name: 'build integration tests binary', command: 'go test -tags "sqlite_unlock_notify" -c ./tests -o ./bin/integration-tests' },
|
{ type: 'run', name: 'build integration tests binary', command: 'go test -tags "sqlite_unlock_notify" -c ./tests -o ./bin/integration-tests' },
|
||||||
{ type: 'run', name: 'run tests', command: 'SKIP_DOCKER_TESTS=1 SKIP_K8S_TESTS=1 go test -v -count 1 $(go list ./... | grep -v /tests)' },
|
{ type: 'run', name: 'run tests', command: 'SKIP_DOCKER_TESTS=1 SKIP_K8S_TESTS=1 go test -v -count 1 $(go list ./... | grep -v /tests)' },
|
||||||
{ type: 'run', name: 'fetch gitea binary for integration tests', command: 'curl -L https://github.com/go-gitea/gitea/releases/download/v1.8.3/gitea-1.8.3-linux-amd64 -o ./bin/gitea && chmod +x ./bin/gitea' },
|
{ type: 'run', name: 'fetch gitea binary for integration tests', command: 'curl -L https://github.com/go-gitea/gitea/releases/download/v1.8.3/gitea-1.8.3-linux-amd64 -o ./bin/gitea && chmod +x ./bin/gitea' },
|
||||||
{ type: 'save_to_workspace', contents: [{ source_dir: './bin', dest_dir: '/bin/', paths: ['*'] }] },
|
{ type: 'save_to_workspace', contents: [{ source_dir: './bin', dest_dir: '/bin/', paths: ['*'] }] },
|
||||||
],
|
],
|
||||||
|
@ -54,6 +54,51 @@ local task_build_docker_tests(version, arch) = {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
local task_build_push_images(name, target, push) =
|
||||||
|
/*
|
||||||
|
* Currently, kaniko, has some issues with multi stage builds where it removes
|
||||||
|
* all the files in the container after every stage (excluding /kaniko) causing
|
||||||
|
* file not found errors when doing COPY commands.
|
||||||
|
* Workaround this buy putting all files inside /kaniko
|
||||||
|
*/
|
||||||
|
local options = if !push then '--no-push' else '--destination sorintlab/%s:$AGOLA_GIT_TAG' % [target];
|
||||||
|
{
|
||||||
|
name: name,
|
||||||
|
runtime: {
|
||||||
|
arch: 'amd64',
|
||||||
|
containers: [
|
||||||
|
{
|
||||||
|
image: 'gcr.io/kaniko-project/executor:debug-v0.11.0',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
environment: {
|
||||||
|
DOCKERAUTH: { from_variable: 'dockerauth' },
|
||||||
|
},
|
||||||
|
shell: '/busybox/sh',
|
||||||
|
working_dir: '/kaniko',
|
||||||
|
steps: [
|
||||||
|
{ type: 'restore_workspace', dest_dir: '/kaniko/agola' },
|
||||||
|
] + std.prune([
|
||||||
|
if push then {
|
||||||
|
type: 'run',
|
||||||
|
name: 'generate docker auth',
|
||||||
|
command: |||
|
||||||
|
cat << EOF > /kaniko/.docker/config.json
|
||||||
|
{
|
||||||
|
"auths": {
|
||||||
|
"https://index.docker.io/v1/": { "auth" : "$DOCKERAUTH" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|||,
|
||||||
|
},
|
||||||
|
]) + [
|
||||||
|
{ type: 'run', command: '/kaniko/executor --context=dir:///kaniko/agola --build-arg AGOLAWEB_IMAGE=sorintlab/agola-web:v0.1.1 --target %s %s' % [target, options] },
|
||||||
|
],
|
||||||
|
depends: ['checkout code and save to workspace', 'integration tests', 'test docker driver'],
|
||||||
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
runs: [
|
runs: [
|
||||||
{
|
{
|
||||||
|
@ -98,6 +143,44 @@ local task_build_docker_tests(version, arch) = {
|
||||||
'build go 1.12 amd64',
|
'build go 1.12 amd64',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'checkout code and save to workspace',
|
||||||
|
runtime: {
|
||||||
|
arch: 'amd64',
|
||||||
|
containers: [
|
||||||
|
{
|
||||||
|
image: 'alpine/git',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{ type: 'clone' },
|
||||||
|
{ type: 'save_to_workspace', contents: [{ source_dir: '.', dest_dir: '.', paths: ['**'] }] },
|
||||||
|
],
|
||||||
|
depends: [],
|
||||||
|
},
|
||||||
|
task_build_push_images('test build docker "agola" image', 'agola', false) + {
|
||||||
|
when: {
|
||||||
|
branch: '#.*#',
|
||||||
|
ref: '#refs/pull/\\d+/head#',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
task_build_push_images('test build docker "agolademo" image', 'agolademo', false) + {
|
||||||
|
when: {
|
||||||
|
branch: '#.*#',
|
||||||
|
ref: '#refs/pull/\\d+/head#',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
task_build_push_images('build and push docker "agola" image', 'agola', true) + {
|
||||||
|
when: {
|
||||||
|
tag: '#v.*#',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
task_build_push_images('build and push docker "agolademo" image', 'agolademo', true) + {
|
||||||
|
when: {
|
||||||
|
tag: '#v.*#',
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
ARG AGOLAWEB_IMAGE="agola-web"
|
||||||
|
|
||||||
|
FROM $AGOLAWEB_IMAGE as agola-web
|
||||||
|
|
||||||
#######
|
#######
|
||||||
####### Build the backend
|
####### Build the backend
|
||||||
#######
|
#######
|
||||||
|
@ -16,6 +20,7 @@ COPY go.sum .
|
||||||
|
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
|
|
||||||
# builds the agola binaries
|
# builds the agola binaries
|
||||||
FROM build_base AS server_builder
|
FROM build_base AS server_builder
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue