Skip to content

Commit

Permalink
Merge pull request #4 from DataDog/sarahchen6/add-github-workflow
Browse files Browse the repository at this point in the history
Add github actions workflow
  • Loading branch information
sarahchen6 authored Sep 27, 2024
2 parents aa532a3 + b21b304 commit e5655db
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 18 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build Catadog

on:
workflow_dispatch:
inputs:
push:
description: Push images
required: true
type: boolean
default: true
push:
branches:
- "**"

jobs:
build:
runs-on: ubuntu-latest
name: Build Docker image
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4

# Use docker-container engine to enable advanced buildx features
- name: Set up docker container engine
run: |
docker buildx create --name=container --driver=docker-container --use --bootstrap

This comment has been minimized.

Copy link
@sarahchen6

sarahchen6 Sep 30, 2024

Author Contributor

Suspected flakiness. Received a 401 not authorized when attempting to pull buildkit image from docker.io. This could possibly be because of rate limits.

# Build image for x86-64
#
# Tag image separately to avoid interference with caching and so that testing step can reference the image
- name: Build single-arch image (x86-64)
run: |
docker buildx build . --builder=container --cache-from=type=registry,ref=ghcr.io/datadog/catadog --output=type=image,push=false --platform linux/x86_64 -f ./Dockerfile
- name: Tag single-arch image (x86-64)
run: |
docker buildx build . --builder=container --cache-from=type=registry,ref=ghcr.io/datadog/catadog --load --platform linux/x86_64 -f ./Dockerfile --tag ghcr.io/datadog/catadog
- name: Test single-arch image (x86-64)
run: |
docker run --platform linux/x86_64 --rm ghcr.io/datadog/catadog /bin/sh -c 'true'
docker run --platform linux/x86_64 --rm ghcr.io/datadog/catadog ruby -e 'puts RUBY_DESCRIPTION'
docker run --platform linux/x86_64 --rm ghcr.io/datadog/catadog gem --version
docker run --platform linux/x86_64 --rm ghcr.io/datadog/catadog bundle --version
docker run --platform linux/x86_64 --rm -v "${PWD}":"${PWD}" -w "${PWD}" ghcr.io/datadog/catadog /bin/sh -c 'bundle install && bundle exec rake test'
# Build image for aarch64-linux, emulated under qemu
#
# Tag image separately to avoid interference with caching and so that testing step can reference the image
- name: Enable aarch64 emulation (x86-64)
run: |
docker run --privileged --rm tonistiigi/binfmt --install arm64
- name: Build single-arch image (aarch64-linux)
run: |
docker buildx build . --builder=container --cache-from=type=registry,ref=ghcr.io/datadog/catadog --output=type=image,push=false --platform linux/aarch64 -f ./Dockerfile
- name: Tag single-arch image (aarch64-linux)
run: |
docker buildx build . --builder=container --cache-from=type=registry,ref=ghcr.io/datadog/catadog --load --platform linux/aarch64 -f ./Dockerfile --tag ghcr.io/datadog/catadog
- name: Test single-arch image (aarch64-linux)
run: |
docker run --platform linux/aarch64 --rm ghcr.io/datadog/catadog /bin/sh -c 'true'
docker run --platform linux/aarch64 --rm ghcr.io/datadog/catadog ruby -e 'puts RUBY_DESCRIPTION'
docker run --platform linux/aarch64 --rm ghcr.io/datadog/catadog gem --version
docker run --platform linux/aarch64 --rm ghcr.io/datadog/catadog bundle --version
docker run --platform linux/aarch64 --rm -v "${PWD}":"${PWD}" -w "${PWD}" ghcr.io/datadog/catadog /bin/sh -c 'bundle install && bundle exec rake test'
# Assemble multi-arch image for a combined push to the registry
#
# Docker build is rerun, but build is fast because the layers are already cached
- name: Log in to the container registry
if: ${{ inputs.push }}
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build multi-arch image (x86-64, aarch64)
if: ${{ inputs.push }}
run: |
docker buildx build . --builder=container --cache-from=type=registry,ref=ghcr.io/datadog/catadog --output=type=image,push=true --build-arg BUILDKIT_INLINE_CACHE=1 --platform linux/x86_64,linux/aarch64 -f ./Dockerfile --tag ghcr.io/datadog/catadog
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ end
group :dev do
gem "pry"
end

gem "ostruct", "~> 0.6.0"
35 changes: 18 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3.4)
activesupport (7.2.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.8)
coderay (1.1.3)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
csv (3.3.0)
drb (2.2.1)
Expand All @@ -41,23 +42,23 @@ GEM
ffi (1.17.0-x86_64-linux-gnu)
ffi (1.17.0-x86_64-linux-musl)
fileutils (1.7.2)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.0)
logger (1.6.1)
method_source (1.1.0)
minitest (5.24.1)
minitest (5.25.1)
msgpack (1.7.2)
mustermann (3.0.1)
mustermann (3.0.3)
ruby2_keywords (~> 0.0.1)
mutex_m (0.2.0)
parallel (1.25.1)
parser (3.3.4.1)
ostruct (0.6.0)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
pry (0.14.2)
Expand All @@ -73,11 +74,10 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rbs (3.5.2)
rbs (3.5.3)
logger
regexp_parser (2.9.2)
rexml (3.3.4)
strscan
rexml (3.3.7)
rubocop (1.52.1)
json (~> 2.3)
parallel (~> 1.10)
Expand All @@ -88,7 +88,7 @@ GEM
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-performance (1.18.0)
rubocop (>= 1.7.0, < 2.0)
Expand Down Expand Up @@ -134,7 +134,7 @@ GEM
tilt (2.4.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
webrick (1.8.1)

PLATFORMS
Expand All @@ -152,6 +152,7 @@ PLATFORMS

DEPENDENCIES
catadog!
ostruct (~> 0.6.0)
pry
rake (~> 13.0)
rbs
Expand Down
4 changes: 3 additions & 1 deletion entrypoint.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
if ARGV.empty? || ARGV == %W[bundle exec catadog]
exec "bundle exec catadog -h 0.0.0.0"
else
elsif ARGV[0].start_with?("-")
exec "bundle exec catadog -h 0.0.0.0 #{ARGV.join(" ")}"
else
exec ARGV.join(" ").to_s
end

0 comments on commit e5655db

Please sign in to comment.