Skip to content

Commit

Permalink
[!] examples => src/bin
Browse files Browse the repository at this point in the history
  • Loading branch information
nykma committed Sep 21, 2022
1 parent a65e730 commit 14e83bf
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/binary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ jobs:

- name: Build
run: |
cargo build --examples --release
strip target/release/examples/lambda
strip target/release/examples/standalone
cargo build --bins --release
strip target/release/lambda
strip target/release/standalone
- name: Artifact
uses: actions/upload-artifact@v3
with:
name: release
path: |
target/release/examples/lambda
target/release/examples/standalone
target/release/lambda
target/release/standalone
2 changes: 1 addition & 1 deletion .github/workflows/container.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build container
nname: Build container

on:
push:
Expand Down
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ readme = "README.org"
repository = "https://github.com/nextdotid/relation_server"
publish = false

[[bin]]
name = "standalone"
test = false
bench = false

[[bin]]
name = "lambda"
test = false
bench = false

[dependencies]
config = "0.12"
lazy_static = "1.4"
Expand Down
15 changes: 4 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
# Build standalone Docker image
FROM rust:buster AS builder
FROM docker.io/rust:buster AS builder

WORKDIR /app

# Stupid, I know.
# SEE ALSO: https://github.com/rust-lang/cargo/issues/2644
RUN mkdir src && touch src/lib.rs
ADD Cargo.toml .
ADD Cargo.lock .
RUN cargo build --release && rm -r src

ADD . .
RUN cargo build --release --example standalone && strip target/release/examples/standalone
RUN cargo build --bins --release && strip target/release/standalone

# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
FROM debian:buster AS runner
FROM docker.io/debian:buster AS runner
LABEL maintainer="Nyk Ma <[email protected]>"

WORKDIR /app

COPY --from=builder /app/target/release/examples/standalone /app/server
COPY --from=builder /app/target/release/standalone /app/server

RUN chmod a+x server && \
mkdir config && \
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions examples/standalone.rs → src/bin/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use relation_server::{
graph::vertex::contract::ContractLoadFn,
graph::vertex::FromToLoadFn,
graph::vertex::IdentityLoadFn,
upstream::start_fetch_workers,
};
use std::{convert::Infallible, net::SocketAddr};
use warp::{http::Response as HttpResponse, Filter, Rejection};
Expand Down Expand Up @@ -114,6 +115,7 @@ async fn main() -> Result<()> {

let address = SocketAddr::new(config::C.web.listen.parse().unwrap(), config::C.web.port);
println!("Playground: http://{}", address);
start_fetch_workers(4);

warp::serve(routes).run(address).await;

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ pub mod error;
pub mod graph;
pub mod util;

mod upstream;
pub mod upstream;

0 comments on commit 14e83bf

Please sign in to comment.