Skip to content

Commit

Permalink
squash architecture specific contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz committed Jan 20, 2021
1 parent 5bec37e commit 034d478
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
8 changes: 0 additions & 8 deletions src/dev/build/tasks/os_packages/create_os_package_tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,13 @@ export const CreateDockerContexts: Task = {
await runDockerGenerator(config, log, build, {
ubi: false,
context: true,
architecture: 'x64',
image: false,
});
await runDockerGenerator(config, log, build, {
ubi: false,
context: true,
architecture: 'aarch64',
image: false,
});

if (build.isOss()) {
await runDockerGenerator(config, log, build, {
ubi: true,
context: true,
architecture: 'x64',
image: false,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export async function bundleDockerFiles(config: Config, log: ToolingLog, scope:
log.info(
`Generating kibana${scope.imageFlavor}${scope.ubiImageFlavor} docker build context bundle`
);
const contextArchitecture = scope.architecture === 'aarch64' ? '-aarch64' : '';
const dockerFilesDirName = `kibana${scope.imageFlavor}${scope.ubiImageFlavor}-${scope.version}-docker-build-context${contextArchitecture}`;
const dockerFilesDirName = `kibana${scope.imageFlavor}${scope.ubiImageFlavor}-${scope.version}-docker-build-context`;
const dockerFilesBuildDir = resolve(scope.dockerBuildDir, dockerFilesDirName);
const dockerFilesOutputDir = config.resolveFromTarget(`${dockerFilesDirName}.tar.gz`);

Expand Down
6 changes: 4 additions & 2 deletions src/dev/build/tasks/os_packages/docker_generator/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function runDockerGenerator(
log: ToolingLog,
build: Build,
flags: {
architecture: string;
architecture?: string;
context: boolean;
image: boolean;
ubi: boolean;
Expand All @@ -55,7 +55,8 @@ export async function runDockerGenerator(
const imageTag = 'docker.elastic.co/kibana/kibana';
const version = config.getBuildVersion();
const artifactArchitecture = flags.architecture === 'aarch64' ? 'aarch64' : 'x86_64';
const artifactTarball = `kibana${imageFlavor}-${version}-linux-${artifactArchitecture}.tar.gz`;
const artifactPrefix = `kibana${imageFlavor}-${version}-linux`;
const artifactTarball = `${artifactPrefix}-${artifactArchitecture}.tar.gz`;
const artifactsDir = config.resolveFromTarget('.');
const dockerBuildDate = new Date().toISOString();
// That would produce oss, default and default-ubi7
Expand All @@ -69,6 +70,7 @@ export async function runDockerGenerator(
`kibana${imageFlavor}${ubiImageFlavor}-${version}-docker-image${imageArchitecture}.tar.gz`
);
const scope: TemplateContext = {
artifactPrefix,
artifactTarball,
imageFlavor,
version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

export interface TemplateContext {
artifactPrefix: string;
artifactTarball: string;
imageFlavor: string;
version: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ RUN {{packageManager}} install -y findutils tar gzip

{{#usePublicArtifact}}
RUN cd /opt && \
curl --retry 8 -s -L -O https://artifacts.elastic.co/downloads/kibana/{{artifactTarball}} && \
curl --retry 8 -s -L \
--output kibana.tar.gz \
https://artifacts.elastic.co/downloads/kibana/{{artifactPrefix}}-$(arch).tar.gz && \
cd -
{{/usePublicArtifact}}

{{^usePublicArtifact}}
COPY {{artifactTarball}} /opt
COPY {{artifactTarball}} /opt/kibana.tar.gz
{{/usePublicArtifact}}

RUN mkdir /usr/share/kibana
WORKDIR /usr/share/kibana
RUN tar --strip-components=1 -zxf /opt/{{artifactTarball}}
RUN tar --strip-components=1 -zxf /opt/kibana.tar.gz
# Ensure that group permissions are the same as user permissions.
# This will help when relying on GID-0 to run Kibana, rather than UID-1000.
# OpenShift does this, for example.
Expand Down Expand Up @@ -59,8 +61,17 @@ RUN for iter in {1..10}; do \

# Add an init process, check the checksum to make sure it's a match
RUN set -e ; \
TINI_BIN="" ; \
case "$(arch)" in \
aarch64) \
TINI_BIN='tini-arm64' ; \
;; \
x86_64) \
TINI_BIN='tini-amd64' ; \
;; \
*) echo >&2 "Unsupported architecture $(arch)" ; exit 1 ;; \
esac ; \
TINI_VERSION='v0.19.0' ; \
TINI_BIN='{{tiniBin}}' ; \
curl --retry 8 -S -L -O "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/${TINI_BIN}" ; \
curl --retry 8 -S -L -O "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/${TINI_BIN}.sha256sum" ; \
sha256sum -c "${TINI_BIN}.sha256sum" ; \
Expand Down

0 comments on commit 034d478

Please sign in to comment.