Skip to content

Commit

Permalink
[Build] Fix Docker image build process (#289)
Browse files Browse the repository at this point in the history
* Fix Dockerfile to build OpenSearch-Dashboards

The Dockerfile was still building kibana so updated to build OpenSearch-Dashboards.
Some fields in the Docker image labels may need updating but setting to some fairly sensible values for now.
Additionally some future work to be done around public artefacts that AFAIK don't exist yet.
Signed-off-by: Jonathan Gough <jonathanpgough@gmail.com>

* Change docker image host to opensearch.org

This needs eventually updating to a correct URI but for now this should suffice
Signed-off-by: Jonathan Gough <jonathanpgough@gmail.com>

* Removing x-pack code

Signed-off-by: Jonathan Gough <jonathanpgough@gmail.com>

* Update name to OpenSearch Dashboards

Signed-off-by: Jonathan Gough <jonathanpgough@gmail.com>
  • Loading branch information
jgough authored and kavilla committed May 21, 2021
1 parent 1613832 commit ae26231
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 43 deletions.
4 changes: 2 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 @@ -48,14 +48,14 @@ export async function runDockerGenerator(
ubi: boolean = false
) {
// UBI var config
const baseOSImage = ubi ? 'docker.opensearch.co/ubi8/ubi-minimal:latest' : 'centos:8';
const baseOSImage = ubi ? 'docker.opensearch.org/ubi8/ubi-minimal:latest' : 'centos:8';
const ubiVersionTag = 'ubi8';
const ubiImageFlavor = ubi ? `-${ubiVersionTag}` : '';

// General docker var config
const license = 'ASL 2.0';
const imageFlavor = '';
const imageTag = 'docker.opensearch.co/opensearch-dashboards/opensearch-dashboards';
const imageTag = 'docker.opensearch.org/opensearch-dashboards/opensearch-dashboards';
const version = config.getBuildVersion();
const artifactTarball = `opensearch-dashboards${imageFlavor}-${version}-linux-x86_64.tar.gz`;
const artifactsDir = config.resolveFromTarget('.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

################################################################################
# Build stage 0 `builder`:
# Extract Kibana artifact
# Extract OpenSearch Dashboards artifact
################################################################################
FROM {{{baseOSImage}}} AS builder

Expand All @@ -16,29 +16,30 @@ RUN {{packageManager}} install -y findutils tar gzip
{{/ubi}}

{{#usePublicArtifact}}
RUN cd /opt && \
curl --retry 8 -s -L -O https://artifacts.opensearch.co/downloads/kibana/{{artifactTarball}} && \
cd -
# TODO: Update this link or remove functionality
# RUN cd /opt && \
# curl --retry 8 -s -L -O https://artifacts.opensearch.co/downloads/opensearch-dashboards/{{artifactTarball}} && \
# cd -
{{/usePublicArtifact}}

{{^usePublicArtifact}}
COPY {{artifactTarball}} /opt
{{/usePublicArtifact}}

RUN mkdir /usr/share/kibana
WORKDIR /usr/share/kibana
RUN mkdir /usr/share/opensearch-dashboards
WORKDIR /usr/share/opensearch-dashboards
RUN tar --strip-components=1 -zxf /opt/{{artifactTarball}}
# 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.
# This will help when relying on GID-0 to run OpenSearch Dashboards, rather than UID-1000.
# OpenShift does this, for example.
# REF: https://docs.openshift.org/latest/creating_images/guidelines.html
RUN chmod -R g=u /usr/share/kibana
RUN find /usr/share/kibana -type d -exec chmod g+s {} \;
RUN chmod -R g=u /usr/share/opensearch-dashboards
RUN find /usr/share/opensearch-dashboards -type d -exec chmod g+s {} \;

################################################################################
# Build stage 1 (the actual Kibana image):
# Build stage 1 (the actual OpenSearch Dashboards image):
#
# Copy kibana from stage 0
# Copy opensearch-dashboards from stage 0
# Add entrypoint
################################################################################
FROM {{{baseOSImage}}}
Expand Down Expand Up @@ -68,69 +69,68 @@ RUN curl -L -o /usr/share/fonts/local/NotoSansCJK-Regular.ttc https://github.com
RUN echo "5dcd1c336cc9344cb77c03a0cd8982ca8a7dc97d620fd6c9c434e02dcb1ceeb3 /usr/share/fonts/local/NotoSansCJK-Regular.ttc" | sha256sum -c -
RUN fc-cache -v

# Bring in Kibana from the initial stage.
COPY --from=builder --chown=1000:0 /usr/share/kibana /usr/share/kibana
WORKDIR /usr/share/kibana
RUN ln -s /usr/share/kibana /opt/kibana
# Bring in OpenSearch Dashboards from the initial stage.
COPY --from=builder --chown=1000:0 /usr/share/opensearch-dashboards /usr/share/opensearch-dashboards
WORKDIR /usr/share/opensearch-dashboards
RUN ln -s /usr/share/opensearch-dashboards /opt/opensearch-dashboards

ENV OPENSEARCH_CONTAINER true
ENV PATH=/usr/share/kibana/bin:$PATH
ENV PATH=/usr/share/opensearch-dashboards/bin:$PATH

# Set some Kibana configuration defaults.
COPY --chown=1000:0 config/kibana.yml /usr/share/kibana/config/kibana.yml
# Set some OpenSearch Dashboards configuration defaults.
COPY --chown=1000:0 config/opensearch_dashboards.yml /usr/share/opensearch-dashboards/config/opensearch_dashboards.yml

# Add the launcher/wrapper script. It knows how to interpret environment
# variables and translate them to Kibana CLI options.
COPY --chown=1000:0 bin/kibana-docker /usr/local/bin/
# variables and translate them to OpenSearch Dashboards CLI options.
COPY --chown=1000:0 bin/opensearch-dashboards-docker /usr/local/bin/

# Ensure gid 0 write permissions for OpenShift.
RUN chmod g+ws /usr/share/kibana && \
find /usr/share/kibana -gid 0 -and -not -perm /g+w -exec chmod g+w {} \;
RUN chmod g+ws /usr/share/opensearch-dashboards && \
find /usr/share/opensearch-dashboards -gid 0 -and -not -perm /g+w -exec chmod g+w {} \;

# Remove the suid bit everywhere to mitigate "Stack Clash"
RUN find / -xdev -perm -4000 -exec chmod u-s {} +

# Provide a non-root user to run the process.
RUN groupadd --gid 1000 kibana && \
RUN groupadd --gid 1000 opensearch-dashboards && \
useradd --uid 1000 --gid 1000 \
--home-dir /usr/share/kibana --no-create-home \
kibana
--home-dir /usr/share/opensearch-dashboards --no-create-home \
opensearch-dashboards

LABEL org.label-schema.build-date="{{dockerBuildDate}}" \
org.label-schema.license="{{license}}" \
org.label-schema.name="Kibana" \
org.label-schema.name="OpenSearch Dashboards" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://www.opensearch.co/products/kibana" \
org.label-schema.usage="https://www.opensearch.co/guide/en/kibana/reference/index.html" \
org.label-schema.url="https://www.opensearch.org/" \
org.label-schema.usage="https://www.opensearch.org/" \
org.label-schema.vcs-ref="{{revision}}" \
org.label-schema.vcs-url="https://github.com/opensearch-project/OpenSearch-Dashboards" \
org.label-schema.vendor="Elastic" \
org.label-schema.vendor="OpenSearch" \
org.label-schema.version="{{version}}" \
org.opencontainers.image.created="{{dockerBuildDate}}" \
org.opencontainers.image.documentation="https://www.opensearch.co/guide/en/kibana/reference/index.html" \
org.opencontainers.image.documentation="https://www.opensearch.org/" \
org.opencontainers.image.licenses="{{license}}" \
org.opencontainers.image.revision="{{revision}}" \
org.opencontainers.image.source="https://github.com/opensearch-project/OpenSearch-Dashboards" \
org.opencontainers.image.title="Kibana" \
org.opencontainers.image.url="https://www.opensearch.co/products/kibana" \
org.opencontainers.image.vendor="Elastic" \
org.opencontainers.image.title="OpenSearch Dashboards" \
org.opencontainers.image.url="https://www.opensearch.org/" \
org.opencontainers.image.vendor="OpenSearch" \
org.opencontainers.image.version="{{version}}"

{{#ubi}}
LABEL name="Kibana" \
maintainer="infra@opensearch.co" \
vendor="Elastic" \
LABEL name="OpenSearch Dashboards" \
vendor="OpenSearch" \
version="{{version}}" \
release="1" \
summary="Kibana" \
description="Your window into the Elastic Stack."
summary="OpenSearch Dashboards" \
description="OpenSearch Dashboards for exploring and visualizing OpenSearch data"

RUN mkdir /licenses && \
cp LICENSE.txt /licenses/LICENSE
{{/ubi}}

USER kibana
USER opensearch-dashboards

ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]

CMD ["/usr/local/bin/kibana-docker"]
CMD ["/usr/local/bin/opensearch-dashboards-docker"]
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function generator({ imageFlavor }: TemplateContext) {
server.name: opensearch-dashboards
server.host: "0"
opensearch.hosts: [ "http://opensearch:9200" ]
${!imageFlavor ? 'monitoring.ui.container.opensearch.enabled: true' : ''}
`);
}

Expand Down

0 comments on commit ae26231

Please sign in to comment.