From de5be3aa796b49e2b0a3f9e208d1a166adda2e34 Mon Sep 17 00:00:00 2001 From: sand <sand@autistici.org> Date: Sat, 23 Feb 2019 21:23:20 +0000 Subject: [PATCH] multistage experiment --- Dockerfile | 20 ++++++++++++-- build.sh => grafana-repo.key | 53 ------------------------------------ 2 files changed, 18 insertions(+), 55 deletions(-) rename build.sh => grafana-repo.key (54%) mode change 100755 => 100644 diff --git a/Dockerfile b/Dockerfile index 73909ed..d42a540 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,24 @@ FROM bitnami/minideb:stretch +COPY grafana-repo.key /tmp/grafana-repo.key +RUN apt -q update \ + && env DEBIAN_FRONTEND=noninteractive apt upgrade -y \ + && env DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y \ + ca-certificates gnupg apt-transport-https \ + && apt-key add /tmp/grafana-repo.key \ + && echo "deb https://packages.grafana.com/oss/deb stable main" > /etc/apt/sources.list.d/grafana.list \ + && apt -q update \ + && env DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y -d \ + grafana -COPY build.sh /tmp/build.sh +FROM bitnami/minideb:stretch -RUN /tmp/build.sh && rm /tmp/build.sh +COPY --from=0 /var/cache/apt/archives/grafana*.deb /tmp/ +RUN apt -q update \ + && env DEBIAN_FRONTEND=noninteractive apt upgrade -y \ + && env DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y /tmp/grafana*.deb \ + && apt autoremove -y \ + && apt clean \ + && rm -fr /var/lib/apt/lists/* /tmp/grafana*.deb ENTRYPOINT ["/usr/sbin/grafana-server", "--config=/etc/grafana/grafana.ini", "--packaging=deb", "cfg:default.paths.logs=/var/log/grafana", "cfg:default.paths.data=/var/lib/grafana", "cfg:default.paths.plugins=/var/lib/grafana/plugins", "cfg:default.paths.provisioning=/etc/grafana/provisioning"] diff --git a/build.sh b/grafana-repo.key old mode 100755 new mode 100644 similarity index 54% rename from build.sh rename to grafana-repo.key index acd17f8..c74f292 --- a/build.sh +++ b/grafana-repo.key @@ -1,35 +1,3 @@ -#!/bin/sh -# -# Install script for Grafana inside a Docker container -# (using Debian packages). -# - -# Packages that are only used to build the container. These will be -# removed once we're done. -BUILD_PACKAGES="ca-certificates gnupg apt-transport-https" - -# Packages to install. -PACKAGES=" - grafana -" - -# The default bitnami/minideb image defines an 'install_packages' -# command which is just a convenient helper. Define our own in -# case we are using some other Debian image. -if [ "x$(which install_packages)" = "x" ]; then - install_packages() { - env DEBIAN_FRONTEND=noninteractive apt-get install -qy -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --no-install-recommends "$@" - } -fi - -set -x -set -e - -install_packages ${BUILD_PACKAGES} - -# Install the Grafana apt key and repository. -# Key source: https://packages.grafana.com/gpg.key -apt-key add - <<EOF -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1 @@ -60,24 +28,3 @@ ymdQ1sqe5nKvwG5GvcncPc3O7LMevDBWnpNNkgERnVxCqpm90TuE3ONbirnU4+/S tUsVU1DERc1fjOCnAm4pKIlNYphISIE7OQ== =0pMC -----END PGP PUBLIC KEY BLOCK----- -EOF -echo "deb https://packages.grafana.com/oss/deb stable main" \ - > /etc/apt/sources.list.d/grafana.list - -apt-get update - -install_packages ${PACKAGES} - -# For some reason the Debian package installs the /etc/default file -# with very restrictive permissions. -chmod 644 /etc/default/grafana-server - -# Overlay our configuration on top of /etc. -#rsync -a /tmp/conf/ /etc/ - -# Remove packages used for installation. -apt-get remove -y --purge ${BUILD_PACKAGES} -apt-get autoremove -y -apt-get clean -rm -fr /var/lib/apt/lists/* -rm -fr /tmp/conf -- GitLab