Commit 62d3655d by Leonard Gram

docker: inital copy of the grafana-docker files.

parent 72af8a70
...@@ -89,7 +89,7 @@ jobs: ...@@ -89,7 +89,7 @@ jobs:
name: run linters name: run linters
command: 'gometalinter.v2 --enable-gc --vendor --deadline 10m --disable-all --enable=deadcode --enable=ineffassign --enable=structcheck --enable=unconvert --enable=varcheck ./...' command: 'gometalinter.v2 --enable-gc --vendor --deadline 10m --disable-all --enable=deadcode --enable=ineffassign --enable=structcheck --enable=unconvert --enable=varcheck ./...'
- run: - run:
name: run go vet name: run go vet
command: 'go vet ./pkg/...' command: 'go vet ./pkg/...'
test-frontend: test-frontend:
...@@ -159,6 +159,16 @@ jobs: ...@@ -159,6 +159,16 @@ jobs:
- store_artifacts: - store_artifacts:
path: dist path: dist
build-deploy-docker-master:
docker:
- image: docker:stable-git
steps:
- checkout
- setup_remote_docker
- run: docker info
- run: echo $GRAFANA_VERSION
- run: ./build.sh ${GRAFANA_VERSION}
build-enterprise: build-enterprise:
docker: docker:
- image: grafana/build-container:v0.1 - image: grafana/build-container:v0.1
...@@ -246,7 +256,7 @@ workflows: ...@@ -246,7 +256,7 @@ workflows:
test-and-build: test-and-build:
jobs: jobs:
- build-all: - build-all:
filters: *filter-only-master filters: *filter-not-release
- build-enterprise: - build-enterprise:
filters: *filter-only-master filters: *filter-only-master
- codespell: - codespell:
...@@ -270,7 +280,19 @@ workflows: ...@@ -270,7 +280,19 @@ workflows:
- gometalinter - gometalinter
- mysql-integration-test - mysql-integration-test
- postgres-integration-test - postgres-integration-test
filters: *filter-only-master filters: *filter-only-master
- build-deploy-docker-master:
requires:
- build-all
- test-backend
- test-frontend
- codespell
- gometalinter
- mysql-integration-test
- postgres-integration-test
filters:
branches:
only: grafana-docker
- deploy-enterprise-master: - deploy-enterprise-master:
requires: requires:
- build-all - build-all
......
FROM debian:stretch-slim
ARG GRAFANA_URL="https://s3-us-west-2.amazonaws.com/grafana-releases/master/grafana-latest.linux-x64.tar.gz"
ARG GF_UID="472"
ARG GF_GID="472"
ENV PATH=/usr/share/grafana/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
GF_PATHS_CONFIG="/etc/grafana/grafana.ini" \
GF_PATHS_DATA="/var/lib/grafana" \
GF_PATHS_HOME="/usr/share/grafana" \
GF_PATHS_LOGS="/var/log/grafana" \
GF_PATHS_PLUGINS="/var/lib/grafana/plugins" \
GF_PATHS_PROVISIONING="/etc/grafana/provisioning"
RUN apt-get update && apt-get install -qq -y tar libfontconfig curl ca-certificates && \
mkdir -p "$GF_PATHS_HOME/.aws" && \
curl "$GRAFANA_URL" | tar xfvz - --strip-components=1 -C "$GF_PATHS_HOME" && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* && \
groupadd -r -g $GF_GID grafana && \
useradd -r -u $GF_UID -g grafana grafana && \
mkdir -p "$GF_PATHS_PROVISIONING/datasources" \
"$GF_PATHS_PROVISIONING/dashboards" \
"$GF_PATHS_LOGS" \
"$GF_PATHS_PLUGINS" \
"$GF_PATHS_DATA" && \
cp "$GF_PATHS_HOME/conf/sample.ini" "$GF_PATHS_CONFIG" && \
cp "$GF_PATHS_HOME/conf/ldap.toml" /etc/grafana/ldap.toml && \
chown -R grafana:grafana "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" && \
chmod 777 "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS"
EXPOSE 3000
COPY ./run.sh /run.sh
USER grafana
WORKDIR /
ENTRYPOINT [ "/run.sh" ]
\ No newline at end of file
#!/bin/sh
_grafana_tag=$1
_grafana_version=$(echo ${_grafana_tag} | cut -d "v" -f 2)
_docker_repo=${2:-grafana/grafana}
echo ${_grafana_version}
if [ "$_grafana_version" != "" ]; then
echo "Building version ${_grafana_version}"
docker build \
--build-arg GRAFANA_URL="https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-${_grafana_version}.linux-amd64.tar.gz" \
--tag "${_docker_repo}:${_grafana_version}" \
--no-cache=true .
docker tag ${_docker_repo}:${_grafana_version} ${_docker_repo}:latest
else
echo "Building latest for master"
docker build \
--tag "grafana/grafana:master" \
.
fi
#!/bin/sh
_grafana_tag=$1
_grafana_version=$(echo ${_grafana_tag} | cut -d "v" -f 2)
if [ "$_grafana_version" != "" ]; then
echo "pushing grafana/grafana:${_grafana_version}"
docker push grafana/grafana:${_grafana_version}
if echo "$_grafana_version" | grep -viqF beta; then
echo "pushing grafana/grafana:latest"
docker push grafana/grafana:latest
fi
else
echo "pushing grafana/grafana:master"
docker push grafana/grafana:master
fi
#!/bin/bash -e
PERMISSIONS_OK=0
if [ ! -r "$GF_PATHS_CONFIG" ]; then
echo "GF_PATHS_CONFIG='$GF_PATHS_CONFIG' is not readable."
PERMISSIONS_OK=1
fi
if [ ! -w "$GF_PATHS_DATA" ]; then
echo "GF_PATHS_DATA='$GF_PATHS_DATA' is not writable."
PERMISSIONS_OK=1
fi
if [ ! -r "$GF_PATHS_HOME" ]; then
echo "GF_PATHS_HOME='$GF_PATHS_HOME' is not readable."
PERMISSIONS_OK=1
fi
if [ $PERMISSIONS_OK -eq 1 ]; then
echo "You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migration-from-a-previous-version-of-the-docker-container-to-5-1-or-later"
fi
if [ ! -d "$GF_PATHS_PLUGINS" ]; then
mkdir "$GF_PATHS_PLUGINS"
fi
if [ ! -z ${GF_AWS_PROFILES+x} ]; then
> "$GF_PATHS_HOME/.aws/credentials"
for profile in ${GF_AWS_PROFILES}; do
access_key_varname="GF_AWS_${profile}_ACCESS_KEY_ID"
secret_key_varname="GF_AWS_${profile}_SECRET_ACCESS_KEY"
region_varname="GF_AWS_${profile}_REGION"
if [ ! -z "${!access_key_varname}" -a ! -z "${!secret_key_varname}" ]; then
echo "[${profile}]" >> "$GF_PATHS_HOME/.aws/credentials"
echo "aws_access_key_id = ${!access_key_varname}" >> "$GF_PATHS_HOME/.aws/credentials"
echo "aws_secret_access_key = ${!secret_key_varname}" >> "$GF_PATHS_HOME/.aws/credentials"
if [ ! -z "${!region_varname}" ]; then
echo "region = ${!region_varname}" >> "$GF_PATHS_HOME/.aws/credentials"
fi
fi
done
chmod 600 "$GF_PATHS_HOME/.aws/credentials"
fi
# Convert all environment variables with names ending in _FILE into the content of
# the file that they point at and use the name without the trailing _FILE.
# This can be used to carry in Docker secrets.
for VAR_NAME in $(env | grep '^GF_[^=]\+_FILE=.\+' | sed -r "s/([^=]*)_FILE=.*/\1/g"); do
VAR_NAME_FILE="$VAR_NAME"_FILE
if [ "${!VAR_NAME}" ]; then
echo >&2 "ERROR: Both $VAR_NAME and $VAR_NAME_FILE are set (but are exclusive)"
exit 1
fi
echo "Getting secret $VAR_NAME from ${!VAR_NAME_FILE}"
export "$VAR_NAME"="$(< "${!VAR_NAME_FILE}")"
unset "$VAR_NAME_FILE"
done
export HOME="$GF_PATHS_HOME"
if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then
OLDIFS=$IFS
IFS=','
for plugin in ${GF_INSTALL_PLUGINS}; do
IFS=$OLDIFS
grafana-cli --pluginsDir "${GF_PATHS_PLUGINS}" plugins install ${plugin}
done
fi
exec grafana-server \
--homepath="$GF_PATHS_HOME" \
--config="$GF_PATHS_CONFIG" \
"$@" \
cfg:default.log.mode="console" \
cfg:default.paths.data="$GF_PATHS_DATA" \
cfg:default.paths.logs="$GF_PATHS_LOGS" \
cfg:default.paths.plugins="$GF_PATHS_PLUGINS" \
cfg:default.paths.provisioning="$GF_PATHS_PROVISIONING"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment