Skip to content

Commit

Permalink
multiarch docker packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
jancajthaml authored Nov 24, 2021
1 parent 394b734 commit e74fdc6
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 113 deletions.
162 changes: 81 additions & 81 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ workflows:
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
- package-docker:
matrix:
parameters:
arch: [amd64, arm64]
requires:
- unit-test
- package-debian-amd64
Expand All @@ -81,11 +84,11 @@ workflows:
tags:
only: /^v[0-9]+(\.[0-9]+)*$/
- blackbox-test:
requires:
- package-docker
matrix:
parameters:
arch: [amd64, arm64]
requires:
- package-docker
filters:
branches:
ignore: /.*/
Expand Down Expand Up @@ -125,6 +128,9 @@ workflows:
- compile-arm64
- versions
- package-docker:
matrix:
parameters:
arch: [amd64, arm64]
requires:
- unit-test
- package-debian-amd64
Expand Down Expand Up @@ -186,23 +192,23 @@ jobs:

checkout:
executor: git
working_directory: /mnt/ramdisk
working_directory: /home/circleci/project
steps:
- checkout
- save_cache:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- /mnt/ramdisk/.git
- /mnt/ramdisk/dev
- /mnt/ramdisk/services
- /mnt/ramdisk/packaging
- /mnt/ramdisk/Dockerfile
- /home/circleci/project/.git
- /home/circleci/project/dev
- /home/circleci/project/services
- /home/circleci/project/packaging
- /home/circleci/project/Dockerfile

# -------------------------------------------------------------------------- #

versions:
executor: git
working_directory: /mnt/ramdisk
working_directory: /home/circleci/project
steps:
- checkout
- run:
Expand All @@ -216,44 +222,44 @@ jobs:
VERSION=${tags}
fi
META=$(echo -e ${CIRCLE_BRANCH} | sed 's:.*/::')
echo -e "${VERSION#v}" > /mnt/ramdisk/VERSION
echo -e "${META}" > /mnt/ramdisk/META
echo -e "${VERSION#v}" > /home/circleci/project/VERSION
echo -e "${META}" > /home/circleci/project/META
else
echo -e "${CIRCLE_TAG#v}" > /mnt/ramdisk/VERSION
echo -e "main" > /mnt/ramdisk/META
echo -e "${CIRCLE_TAG#v}" > /home/circleci/project/VERSION
echo -e "main" > /home/circleci/project/META
fi
- save_cache:
key: versions-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- /mnt/ramdisk/VERSION
- /mnt/ramdisk/META
- /home/circleci/project/VERSION
- /home/circleci/project/META

# -------------------------------------------------------------------------- #

deps:
executor: scala
working_directory: /mnt/ramdisk
working_directory: /home/circleci/project
steps:
- restore_cache:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Sync data-warehouse dependencies
command: |
/mnt/ramdisk/dev/lifecycle/sync \
--source /mnt/ramdisk/services/data-warehouse
/home/circleci/project/dev/lifecycle/sync \
--source /home/circleci/project/services/data-warehouse
- save_cache:
key: dependencies-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- /mnt/ramdisk/services/data-warehouse/.ivy
- /mnt/ramdisk/services/data-warehouse/target
- /mnt/ramdisk/services/data-warehouse/project/project
- /mnt/ramdisk/services/data-warehouse/project/target
- /home/circleci/project/services/data-warehouse/.ivy
- /home/circleci/project/services/data-warehouse/target
- /home/circleci/project/services/data-warehouse/project/project
- /home/circleci/project/services/data-warehouse/project/target

# -------------------------------------------------------------------------- #

unit-test:
executor: scala
working_directory: /mnt/ramdisk
working_directory: /home/circleci/project
steps:
- restore_cache:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
Expand All @@ -262,18 +268,18 @@ jobs:
- run:
name: Unit test data-warehouse
command: |
/mnt/ramdisk/dev/lifecycle/test \
--source /mnt/ramdisk/services/data-warehouse \
--output /mnt/ramdisk/reports
/home/circleci/project/dev/lifecycle/test \
--source /home/circleci/project/services/data-warehouse \
--output /home/circleci/project/reports
no_output_timeout: 5m
- store_test_results:
path: /mnt/ramdisk/reports/unit-tests
path: /home/circleci/project/reports/unit-tests

# -------------------------------------------------------------------------- #

compile-amd64:
executor: scala
working_directory: /mnt/ramdisk
working_directory: /home/circleci/project
steps:
- restore_cache:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
Expand All @@ -282,15 +288,15 @@ jobs:
- run:
name: Compile data-warehouse binary
command: |
/mnt/ramdisk/dev/lifecycle/package \
/home/circleci/project/dev/lifecycle/package \
--arch linux/amd64 \
--source /mnt/ramdisk/services/data-warehouse \
--output /mnt/ramdisk/packaging/bin
--source /home/circleci/project/services/data-warehouse \
--output /home/circleci/project/packaging/bin
no_output_timeout: 5m
- save_cache:
key: binaries-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- /mnt/ramdisk/packaging/bin
- /home/circleci/project/packaging/bin

# -------------------------------------------------------------------------- #

Expand All @@ -305,21 +311,21 @@ jobs:
- run:
name: Compile data-warehouse binary
command: |
/mnt/ramdisk/dev/lifecycle/package \
/home/circleci/project/dev/lifecycle/package \
--arch linux/arm64 \
--source /mnt/ramdisk/services/data-warehouse \
--output /mnt/ramdisk/packaging/bin
--source /home/circleci/project/services/data-warehouse \
--output /home/circleci/project/packaging/bin
no_output_timeout: 5m
- save_cache:
key: binaries-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- /mnt/ramdisk/packaging/bin
- /home/circleci/project/packaging/bin

# -------------------------------------------------------------------------- #

package-debian-amd64:
executor: debian
working_directory: /mnt/ramdisk
working_directory: /home/circleci/project
steps:
- restore_cache:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
Expand All @@ -330,23 +336,23 @@ jobs:
- run:
name: Package for debian
command: |
VERSION=$(cat /mnt/ramdisk/VERSION)
/mnt/ramdisk/dev/lifecycle/debian \
VERSION=$(cat /home/circleci/project/VERSION)
/home/circleci/project/dev/lifecycle/debian \
--arch amd64 \
--pkg data-warehouse \
--version ${VERSION} \
--source /mnt/ramdisk/packaging
--source /home/circleci/project/packaging
no_output_timeout: 5m
- save_cache:
key: debian-amd64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- /mnt/ramdisk/packaging/bin
- /home/circleci/project/packaging/bin

# -------------------------------------------------------------------------- #

package-debian-arm64:
executor: debian
working_directory: /mnt/ramdisk
working_directory: /home/circleci/project
steps:
- restore_cache:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
Expand All @@ -357,24 +363,26 @@ jobs:
- run:
name: Package for debian
command: |
VERSION=$(cat /mnt/ramdisk/VERSION)
/mnt/ramdisk/dev/lifecycle/debian \
VERSION=$(cat /home/circleci/project/VERSION)
/home/circleci/project/dev/lifecycle/debian \
--arch arm64 \
--pkg data-warehouse \
--version ${VERSION} \
--source /mnt/ramdisk/packaging
--source /home/circleci/project/packaging
no_output_timeout: 5m
- save_cache:
key: debian-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- /mnt/ramdisk/packaging/bin
- /home/circleci/project/packaging/bin

# -------------------------------------------------------------------------- #

package-docker:
docker:
- image: docker.io/docker:18.06.0-ce-git
working_directory: /mnt/ramdisk
parameters:
arch:
type: string
executor: machine-<< parameters.arch >>
working_directory: /home/circleci/project
steps:
- restore_cache:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
Expand All @@ -388,45 +396,37 @@ jobs:
key: debian-arm64-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
key: versions-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
- setup_remote_docker:
version: 18.06.0-ce
- run:
name: Package for docker
name: Publish << parameters.arch >> to docker.io
command: |
VERSION=$(cat /mnt/ramdisk/VERSION)
META=$(cat /mnt/ramdisk/META)
export VERSION=$(cat /home/circleci/project/VERSION)
export META=$(cat /home/circleci/project/META)
export ARCH=<< parameters.arch >>
docker build \
-t docker.io/openbank/data-warehouse:v${VERSION}-${META} \
-f packaging/docker/Dockerfile \
.
docker build \
-t docker.pkg.github.com/jancajthaml-openbank/data-warehouse/data-warehouse:${VERSION} \
-f packaging/docker/Dockerfile \
.
- run:
name: Publish to docker.io
command: |
-t docker.io/openbank/data-warehouse:${ARCH}-${VERSION}.${META} \
-f ./packaging/docker/${ARCH}/Dockerfile .
echo ${DOCKER_PASSWORD} | docker login docker.io -u ${DOCKER_USER} --password-stdin
VERSION=$(cat /mnt/ramdisk/VERSION)
META=$(cat /mnt/ramdisk/META)
docker push \
docker.io/openbank/data-warehouse:v${VERSION}-${META}
rm -f /root/.docker/config.json
docker push docker.io/openbank/data-warehouse:${ARCH}-${VERSION}.${META}
rm -f /home/circleci/.docker/config.json
- run:
name: Publish to docker.pkg.github.com
name: Publish << parameters.arch >> to docker.pkg.github.com
command: |
export VERSION=$(cat /home/circleci/project/VERSION)
export ARCH=<< parameters.arch >>
docker build \
-t docker.pkg.github.com/jancajthaml-openbank/data-warehouse/data-warehouse:${ARCH}-${VERSION} \
-f ./packaging/docker/${ARCH}/Dockerfile .
echo ${GITHUB_RELEASE_TOKEN} | docker login docker.pkg.github.com -u ${DOCKER_USER} --password-stdin
VERSION=$(cat /mnt/ramdisk/VERSION)
docker push \
docker.pkg.github.com/jancajthaml-openbank/data-warehouse/data-warehouse:${VERSION}
docker push docker.pkg.github.com/jancajthaml-openbank/data-warehouse/data-warehouse:${ARCH}-${VERSION}
rm -f /root/.docker/config.json
rm -f /home/circleci/.docker/config.json
# -------------------------------------------------------------------------- #

Expand Down Expand Up @@ -459,7 +459,7 @@ jobs:
- run:
name: Run blackbox tests
command: |
export VERSION=v$(cat /home/circleci/project/VERSION)
export VERSION=$(cat /home/circleci/project/VERSION)
export META=$(cat /home/circleci/project/META)
export ARCH=<< parameters.arch >>
Expand All @@ -477,7 +477,7 @@ jobs:

release:
executor: debian
working_directory: /mnt/ramdisk
working_directory: /home/circleci/project
steps:
- restore_cache:
key: code-{{ .Environment.CIRCLE_TAG }}-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_SHA1 }}
Expand All @@ -492,7 +492,7 @@ jobs:
- deploy:
name: Release artifacts to github
command: |
/mnt/ramdisk/dev/lifecycle/release \
/home/circleci/project/dev/lifecycle/release \
--version ${CIRCLE_TAG} \
--token ${GITHUB_RELEASE_TOKEN}
Expand Down
4 changes: 2 additions & 2 deletions .jenkins/commit.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def dockerOptions() {
options += "--label 'org.opencontainers.image.authors=${env.PROJECT_AUTHOR}' "
options += "--label 'org.opencontainers.image.title=${env.PROJECT_NAME}' "
options += "--label 'org.opencontainers.image.description=${env.PROJECT_DESCRIPTION}' "
options += "-f packaging/docker/Dockerfile "
options += "-f packaging/docker/amd64/Dockerfile "
options += "."
return options
}
Expand Down Expand Up @@ -234,7 +234,7 @@ pipeline {
stage('Package Docker') {
steps {
script {
DOCKER_IMAGE = docker.build("${env.ARTIFACTORY_DOCKER_REGISTRY}/docker-local/openbank/data-warehouse:${env.VERSION}", dockerOptions())
DOCKER_IMAGE = docker.build("${env.ARTIFACTORY_DOCKER_REGISTRY}/docker-local/openbank/data-warehouse:amd64-${env.VERSION}", dockerOptions())
}
}
}
Expand Down
Loading

0 comments on commit e74fdc6

Please sign in to comment.