Skip to content

Commit

Permalink
Merge pull request #209 from umccr/docker
Browse files Browse the repository at this point in the history
Docker release support
  • Loading branch information
mmalenic authored Oct 30, 2023
2 parents 714e261 + 1d636a0 commit 1c53909
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmarking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
contents: write

jobs:
test:
benchmark:
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
26 changes: 20 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ on:
pull_request:

jobs:
test:
build:
runs-on: ${{ matrix.os }}
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
strategy:
matrix:
rust: [stable]
os: [ubuntu-latest]
steps:
- name: Cache
uses: mozilla-actions/sccache-action@v0.0.3
- name: Check out
uses: actions/checkout@v3
- name: Install Rust
Expand All @@ -22,11 +29,6 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
- run: rustup override set ${{ steps.toolchain.outputs.name }}
- name: Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: build-cache
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build all features
uses: actions-rs/cargo@v1
with:
Expand All @@ -47,3 +49,15 @@ jobs:
with:
command: build
args: --all-targets --features url-storage
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Test Docker build
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
file: deploy/Dockerfile
push: false
tags: |
ghcr.io/umccr/htsget-rs:dev-latest
ghcr.io/umccr/htsget-rs:dev-${{ github.run_number }}
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,21 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.HTSGET_RS_CRATES_IO_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR.io (GH's Container Registry)
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker GitHub release
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
file: deploy/Dockerfile
push: true
tags: |
ghcr.io/umccr/htsget-rs:dev-latest
ghcr.io/umccr/htsget-rs:dev-${{ github.run_number }}
12 changes: 7 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@ on:
jobs:
test:
runs-on: ${{ matrix.os }}
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
strategy:
matrix:
rust: [stable]
os: [ubuntu-latest]
steps:
- name: Cache
uses: mozilla-actions/sccache-action@v0.0.3
- name: Check out
uses: actions/checkout@v3
- name: Install Rust
Expand All @@ -23,11 +30,6 @@ jobs:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- run: rustup override set ${{ steps.toolchain.outputs.name }}
- name: Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: build-cache
save-if: false
- name: Cargo fmt
uses: actions-rs/cargo@v1
with:
Expand Down
27 changes: 12 additions & 15 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
# syntax=docker/dockerfile:1.4
FROM rust:1.61.0 AS builder
FROM rust:1.73.0 AS builder

ARG TARGETPLATFORM
WORKDIR /build

WORKDIR /root

RUN --mount=type=cache,target=/usr/local/cargo/registry,id=${TARGETPLATFORM} \
cargo install cargo-strip
RUN cargo install cargo-strip

COPY . .

RUN --mount=type=cache,target=/usr/local/cargo/registry,id=${TARGETPLATFORM} --mount=type=cache,target=/root/target,id=${TARGETPLATFORM} \
cargo build --release && \
cargo strip && \
mv /root/target/release/htsget-actix /root
RUN cargo build --features url-storage --release && \
cargo strip

FROM debian:sid-slim

FROM gcr.io/distroless/cc-debian11
RUN apt update && apt install -y libc6-dev && rm -rf /var/lib/apt/lists/*

COPY --from=builder /root/htsget-actix /
COPY --from=builder /etc/ssl/certs/ /etc/ssl/certs/
COPY --from=builder /build/target/release/htsget-actix /usr/local/bin/htsget-actix

ENTRYPOINT ["./htsget-actix"]
EXPOSE 8080
EXPOSE 8081

EXPOSE 3000
CMD [ "htsget-actix" ]
21 changes: 21 additions & 0 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,27 @@ cargo lambda invoke htsget-lambda --data-file data/events/event_get.json

Examples of different Lambda events are located in the [`data/events`][data-events] directory.

## Docker

There are multiple options to use docker containers with htsget-rs:

### Local

```
$ docker build . -f deploy/Dockerfile -t htsget-rs-actix
$ docker run htsget-rs-actix
% docker run htsget-rs-actix
2023-10-25T01:01:38.412471Z INFO bind_addr{addr=127.0.0.1:8081 cors=CorsConfig { allow_credentials: false, allow_origins: List([HeaderValue("http://localhost:8080")]), allow_headers: Tagged(All), allow_methods: Tagged(All), max_age: 86400, expose_headers: List([]) }}: htsget_search::storage::data_server: data server address bound to address=127.0.0.1:8081
2023-10-25T01:01:38.412710Z INFO run_server: htsget_actix: using non-TLS ticket server
2023-10-25T01:01:38.412805Z INFO run_server: htsget_actix: htsget query server addresses bound addresses=[127.0.0.1:8080]
2023-10-25T01:01:38.412837Z INFO run_server: actix_server::builder: starting 8 workers
2023-10-25T01:01:38.412892Z INFO actix_server::server: Actix runtime found; starting in Actix runtime
```

### Local with MinIO (S3) backend

TBD

[htsget-lambda]: ../htsget-lambda
[cargo-lambda]: https://github.com/cargo-lambda/cargo-lambda
[data-events]: ../data/events
5 changes: 1 addition & 4 deletions htsget-search/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,7 @@ impl Display for BytesRange {
.start
.map(|start| start.to_string())
.unwrap_or_else(|| "0".to_string());
let end = self
.end
.map(|end| end.to_string())
.unwrap_or_else(|| "".to_string());
let end = self.end.map(|end| end.to_string()).unwrap_or_default();
write!(f, "bytes={start}-{end}")
}
}
Expand Down

0 comments on commit 1c53909

Please sign in to comment.