Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
Signed-off-by: Marcelo E. Magallon <marcelo.magallon@grafana.com>
  • Loading branch information
mem committed Dec 4, 2023
1 parent 77e5a9c commit 8b0a961
Show file tree
Hide file tree
Showing 12 changed files with 708 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: "Publish container image"

on:
push:
branches:
- main
tags:
- v*

release:
types:
- published

workflow_dispatch:

jobs:
publish:
name: Publish container images
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true

- name: Unshallow
run: git fetch --prune --tags --unshallow

- name: Describe the current state
run: git describe --tags --always

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{raw}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Package Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
-
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
shell: bash
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Created by https://www.toptal.com/developers/gitignore/api/go
# Edit at https://www.toptal.com/developers/gitignore?templates=go

### Go ###
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

# End of https://www.toptal.com/developers/gitignore/api/go
4 changes: 4 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://help.github.com/articles/about-codeowners/
# https://git-scm.com/docs/gitignore#_pattern_format

* @grafana/grafana-build-tools
46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at conduct@grafana.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
96 changes: 96 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
FROM registry.hub.docker.com/library/golang:1.21.3 as go-build

COPY go.env /usr/local/go

RUN env GOBIN=/build go install github.com/google/go-jsonnet/cmd/jsonnet@v0.20.0
RUN env GOBIN=/build go install github.com/google/go-jsonnet/cmd/jsonnetfmt@v0.20.0
RUN env GOBIN=/build go install github.com/google/go-jsonnet/cmd/jsonnet-deps@v0.20.0
RUN env GOBIN=/build go install github.com/google/go-jsonnet/cmd/jsonnet-lint@v0.20.0

# The grafana/xk6 image only exists for amd64, so we need to build it for
# the target architecture.
RUN env GOBIN=/build go install go.k6.io/xk6/cmd/xk6@v0.9.2

# The grafana/k6 image only exists for amd64, so we need to build it for
# the architecture we are targeting. The simplest way to build k6 is to
# (ab)use xk6 to build a binary without any extensions. In the future, if
# we wanted additional extensions, this is the place to add them.
RUN /build/xk6 build v0.46.0 --output /build/k6

# Add wire
RUN env GOBIN=/build go install github.com/google/wire/cmd/wire@v0.5.0

# Add bingo
RUN env GOBIN=/build go install github.com/bwplotka/bingo@v0.8.0

# Add enumer
RUN env GOBIN=/build go install github.com/dmarkham/enumer@v1.5.7

# Add protoc-gen-go
RUN env GOBIN=/build go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0

# Add protoc-gen-go-grpc
RUN env GOBIN=/build go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0

# Add buf
RUN env GOBIN=/build go install github.com/bufbuild/buf/cmd/buf@v1.26.1

# Add mage
RUN git clone --depth 1 --branch v1.15.0 https://github.com/magefile/mage mage && \
cd mage && \
env GOBIN=/build go run bootstrap.go

# Add nilaway
# This hasn't been released yet, so pin it to a specific version for reproducibility
RUN env GOBIN=/build go install go.uber.org/nilaway/cmd/nilaway@v0.0.0-20231117175943-a267567c6fff

# Add golangci-lint
COPY --from=registry.hub.docker.com/golangci/golangci-lint:v1.55.2 /usr/bin/golangci-lint /build

# Add shellcheck
COPY --from=registry.hub.docker.com/koalaman/shellcheck:v0.9.0 /bin/shellcheck /build

FROM registry.hub.docker.com/library/debian:stable-slim as build

COPY --from=go-build /usr/local/go /usr/local/go

ENV PATH="/usr/local/go/bin:${PATH}"

RUN apt-get update && \
apt-get install -y \
build-essential \
libgpgme-dev \
libassuan-dev \
libdevmapper-dev \
pkg-config \
git

# skopeo is used to inspect container registries. This can be used to
# inspect the available versions without pulling the repos.
RUN git clone https://github.com/containers/skopeo && \
cd skopeo && \
make GOBIN=/build DISABLE_DOCS=1 bin/skopeo && \
mkdir -p /build && \
cp bin/skopeo /build/

FROM registry.hub.docker.com/library/debian:stable-slim

RUN apt-get update && \
apt-get install -y \
build-essential \
docker.io \
file \
git \
pkg-config \
libgpgme11 \
&& \
rm -rf /var/lib/apt/lists

COPY --from=go-build /usr/local/go /usr/local/go
ENV PATH="/usr/local/go/bin:${PATH}"

# Keep tools in /usr/local/bin. That makes it a little bit easier to see
# what comes from the image vs stuff coming from the base image.
COPY --from=go-build /build/* /usr/local/bin/

COPY image-test /usr/local/bin
Loading

0 comments on commit 8b0a961

Please sign in to comment.