Skip to content

Commit

Permalink
attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrankel committed Jan 27, 2025
1 parent 7d4ffc3 commit 4843025
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and push package

on:
# For demo purposes only
workflow_dispatch:
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
strategy:
matrix:
tag: [ "native", "runtime", "embed" ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache build artifacts
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-build-${{ github.sha }}
restore-keys:
${{ runner.os }}-build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.${{ matrix.tag }}
tags: ${{ matrix.tag }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
6 changes: 3 additions & 3 deletions Dockerfile.native
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN <<EOB

apt-get update
apt-get install -y musl-tools musl-dev
rustup target add aarch64-unknown-linux-musl
rustup target add x86_64-unknown-linux-musl

EOB

Expand All @@ -19,10 +19,10 @@ COPY src src

WORKDIR /native

RUN RUSTFLAGS="-C target-feature=+crt-static" cargo build --target aarch64-unknown-linux-musl --release
RUN RUSTFLAGS="-C target-feature=+crt-static" cargo build --target x86_64-unknown-linux-musl --release

FROM gcr.io/distroless/static

COPY --from=build /native/target/aarch64-unknown-linux-musl/release/httpbin httpbin
COPY --from=build /native/target/x86_64-unknown-linux-musl/release/httpbin httpbin

ENTRYPOINT ["./httpbin"]
4 changes: 0 additions & 4 deletions build.sh

This file was deleted.

9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ async fn get(
Query(params): Query<HashMap<String, String>>,
header_map: HeaderMap,
) -> Response {
let headers = header_map.iter().map(|(k, v)| {
let value = v.to_str().unwrap().to_string();
(k.to_string(), value )
}).collect();
//headers.iter().for_each(|(k, v)| println!("{}: {:?}", k, v));
let headers = header_map
.iter()
.map(|(k, v)| (k.to_string(), v.to_str().unwrap().to_string()))
.collect();
let bin_response = BinResponse::new(params, headers, uri.to_string());
Json(bin_response).into_response()
}

0 comments on commit 4843025

Please sign in to comment.