forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup workflow to build and publish docker image with source tarball
oss: Add links to the code and license of where this was built from
- Loading branch information
Kumar Singh, Aman [Engineering]
committed
Apr 23, 2024
1 parent
f4c5a60
commit 05dc3d0
Showing
13 changed files
with
238 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Create and publish a Docker image | ||
|
||
on: [push] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build the container | ||
run: make push_from_dist | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,3 +194,6 @@ deployment_tools_config.json | |
|
||
# Temporary file for backporting PRs | ||
.pr-body.txt | ||
|
||
build_dir/ | ||
grafana-dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
ARG GO_SRC=go-builder | ||
ARG JS_SRC=js-builder | ||
|
||
FROM registry.access.redhat.com/ubi8/nodejs-18:1-81 as js-builder | ||
|
||
ENV NODE_OPTIONS=--max_old_space_size=8000 | ||
|
||
USER root | ||
WORKDIR /grafana | ||
|
||
COPY package.json yarn.lock .yarnrc.yml ./ | ||
COPY .yarn .yarn | ||
COPY packages packages | ||
COPY plugins-bundled plugins-bundled | ||
COPY public public | ||
|
||
RUN npm install -g [email protected] | ||
RUN yarn install --immutable | ||
|
||
COPY tsconfig.json .eslintrc .editorconfig .browserslistrc .prettierrc.js babel.config.json ./ | ||
COPY public public | ||
COPY scripts scripts | ||
COPY emails emails | ||
|
||
ENV NODE_ENV production | ||
RUN yarn build | ||
|
||
FROM registry.access.redhat.com/ubi8/go-toolset:1.20.10-3 as go-builder | ||
|
||
ARG COMMIT_SHA="" | ||
ARG BUILD_BRANCH="" | ||
ARG GO_BUILD_TAGS="oss" | ||
ARG WIRE_TAGS="oss" | ||
ARG BINGO="true" | ||
|
||
# Install build dependencies | ||
RUN if grep -i -q alpine /etc/issue; then \ | ||
apk add --no-cache gcc g++ make git; \ | ||
fi | ||
|
||
USER root | ||
WORKDIR /grafana | ||
|
||
COPY go.* ./ | ||
COPY .bingo .bingo | ||
|
||
RUN go mod download | ||
|
||
COPY embed.go Makefile build.go package.json ./ | ||
COPY cue.mod cue.mod | ||
COPY kinds kinds | ||
COPY local local | ||
COPY packages/grafana-schema packages/grafana-schema | ||
COPY public/app/plugins public/app/plugins | ||
COPY public/api-merged.json public/api-merged.json | ||
COPY pkg pkg | ||
COPY scripts scripts | ||
COPY conf conf | ||
COPY .github .github | ||
COPY LICENSE ./ | ||
|
||
ENV COMMIT_SHA=${COMMIT_SHA} | ||
ENV BUILD_BRANCH=${BUILD_BRANCH} | ||
|
||
RUN go mod verify | ||
RUN make build-go GO_BUILD_TAGS=${GO_BUILD_TAGS} WIRE_TAGS=${WIRE_TAGS} | ||
|
||
# Final stage | ||
# helpers for COPY --from | ||
FROM ${GO_SRC} as go-src | ||
FROM ${JS_SRC} as js-src | ||
|
||
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6-854 | ||
|
||
LABEL maintainer="Grafana team <[email protected]>" | ||
|
||
ARG GF_UID="472" | ||
ARG GF_GID="0" | ||
|
||
ENV PATH="/usr/share/grafana/bin:$PATH" \ | ||
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" | ||
|
||
WORKDIR $GF_PATHS_HOME | ||
USER root | ||
|
||
RUN microdnf install shadow-utils | ||
|
||
COPY conf ./conf | ||
|
||
RUN export GF_GID_NAME=$(getent group $GF_GID | cut -d':' -f1) && \ | ||
mkdir -p "$GF_PATHS_HOME/.aws" && \ | ||
useradd --system -u $GF_UID -G "$GF_GID_NAME" grafana && \ | ||
mkdir -p "$GF_PATHS_PROVISIONING/datasources" \ | ||
"$GF_PATHS_PROVISIONING/dashboards" \ | ||
"$GF_PATHS_PROVISIONING/notifiers" \ | ||
"$GF_PATHS_PROVISIONING/plugins" \ | ||
"$GF_PATHS_PROVISIONING/access-control" \ | ||
"$GF_PATHS_PROVISIONING/alerting" \ | ||
"$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:$GF_GID_NAME" "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" && \ | ||
chmod -R 777 "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" | ||
|
||
COPY --from=go-src /grafana/bin/grafana* /grafana/bin/*/grafana* ./bin/ | ||
COPY --from=js-src /grafana/public ./public | ||
COPY --from=go-src /grafana/LICENSE ./ | ||
COPY public/build/static/source*.tar.gz ./public/build/static/ | ||
|
||
EXPOSE 3000 | ||
|
||
COPY ./packaging/docker/run.sh /run.sh | ||
|
||
USER grafana | ||
ENTRYPOINT [ "/run.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
# Builds the container image from the source tarball. | ||
|
||
set -e | ||
set -o pipefail | ||
|
||
INPUT="$(realpath $1)" | ||
COMMIT="$2" | ||
|
||
echo "Attempting to build ${INPUT}" | ||
mkdir build_dir | ||
tar -C build_dir -xf "${INPUT}" | ||
|
||
# My patch failed with out of memory. Let's use git instead. | ||
cd build_dir/grafana-dist | ||
git init | ||
git config user.email "[email protected]" | ||
git config user.name "Your Name" | ||
git add -A | ||
git commit -m "baseline version" | ||
git am patches/*.patch | ||
|
||
|
||
mkdir -p public/build/static | ||
cp "${INPUT}" public/build/static | ||
docker build --tag ghcr.io/goldmansachs/grafana:9.5.18-ubi8-"${COMMIT}" -f ./Dockerfile.ubi8 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters