Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,50 @@ jobs:
file: target/${{ matrix.target }}/release-ci/${{ matrix.artifact_name }}
asset_name: ${{ matrix.release_name }}
tag: ${{ github.ref }}

docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: publish
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Login to GitHub Container Registry
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
26 changes: 17 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
ARG RUST_VERSION=slim
FROM docker.io/library/rust:${RUST_VERSION} AS build
WORKDIR /app
COPY . /app
FROM docker.io/library/rust:${RUST_VERSION} AS chef

RUN cargo install cargo-chef --locked
RUN apt-get update && apt-get install -y \
cmake \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN cargo install --path .
RUN strip /usr/local/cargo/bin/oha
WORKDIR /app

# Target image
FROM registry.fedoraproject.org/fedora-minimal
USER 65535
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

COPY --chown=65535:65535 --from=build /usr/local/cargo/bin/oha /bin/
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json

RUN cargo chef cook --release --no-default-features --features rustls --recipe-path recipe.json

COPY . .
RUN cargo build --release --no-default-features --features rustls --bin oha
RUN strip /app/target/release/oha

FROM registry.fedoraproject.org/fedora-minimal AS runtime
USER 65535
COPY --chown=65535:65535 --from=builder /app/target/release/oha /bin/
ENTRYPOINT ["/bin/oha"]