Skip to content

Commit df6cce5

Browse files
committed
Set up container build
Signed-off-by: Yuri Shkuro <github@ysh.us>
1 parent 55e16a3 commit df6cce5

File tree

6 files changed

+137
-0
lines changed

6 files changed

+137
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Set up QEMU
26+
uses: docker/setup-qemu-action@v3
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Log in to the Container registry
32+
if: github.event_name != 'pull_request'
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Extract metadata (tags, labels) for Docker
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=raw,value=latest,enable={{is_default_branch}}
46+
type=ref,event=branch
47+
type=ref,event=pr
48+
type=semver,pattern={{version}}
49+
50+
- name: Build and push Docker image
51+
uses: docker/build-push-action@v6
52+
with:
53+
context: .
54+
platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le
55+
push: ${{ github.event_name != 'pull_request' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2025 The Jaeger Authors.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
FROM golang:1.24.1-alpine AS build
5+
ARG TARGETARCH
6+
ENV GOPATH /go
7+
RUN apk add --update --no-cache ca-certificates make git build-base mailcap
8+
9+
WORKDIR /go/src/debug-delve
10+
COPY go.mod tools.go /go/src/debug-delve/
11+
12+
# TODO: Remove s390x once go-delve adds support for it (https://github.com/go-delve/delve/issues/2883)
13+
# TODO: Remove ppc64le once support is released (https://github.com/go-delve/delve/issues/1564)
14+
RUN if [[ "$TARGETARCH" == "s390x" || "$TARGETARCH" == "ppc64le" ]] ; then \
15+
touch /go/bin/dlv; \
16+
else \
17+
go mod download && go build -o /go/bin/dlv github.com/go-delve/delve/cmd/dlv; \
18+
fi
19+
20+
FROM golang:1.24.1-alpine
21+
COPY --from=build /go/bin/dlv /go/bin/dlv
22+
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
23+
COPY --from=build /etc/mime.types /etc/mime.types

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Base Image with Debugger
2+
3+
This repository builds and publishes a base Docker image containing the [Delve](https://github.com/go-delve/delve) debugger. This image is intended to be used as a base for debugging Go applications in containers.
4+
5+
## Image Contents
6+
7+
- Alpine-based Go image
8+
- `dlv` (Delve debugger) installed in `/go/bin/dlv`
9+
- CA certificates and mime types
10+
11+
## Usage
12+
13+
You can use this image in your Dockerfiles:
14+
15+
```dockerfile
16+
FROM ghcr.io/jaegertracing/base-image-with-debugger:latest
17+
# ... your build steps ...
18+
```
19+
20+
## Maintenance
21+
22+
The versions of the base image and Delve are managed by Renovate.

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module debug-delve
2+
3+
go 1.24.1
4+
5+
require github.com/go-delve/delve v1.26.0

renovate.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:best-practices",
5+
":gitSignOff"
6+
],
7+
"labels": [
8+
"changelog:dependencies"
9+
],
10+
"postUpdateOptions": [
11+
"gomodTidy",
12+
"gomodUpdateImportPaths"
13+
]
14+
}

tools.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) 2025 The Jaeger Authors.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
//go:build tools
5+
6+
package tools
7+
8+
// This file follows the recommendation at
9+
// https://go.dev/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
10+
// on how to pin tooling dependencies to a go.mod file.
11+
12+
import (
13+
_ "github.com/go-delve/delve/cmd/dlv"
14+
)

0 commit comments

Comments
 (0)