+++ /dev/null
-version: 2.1
-
-# Define the jobs we want to run for this project
-jobs:
- build:
- machine:
- image: ubuntu
- environment:
- DOCKER_BUILDKIT: 1
- BUILDX_PLATFORMS: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
- steps:
- - checkout
- - run:
- name: Unit Tests
- command: make test
- - run:
- name: Log in to docker hub
- command: |
- docker login -u $DOCKER_USER -p $DOCKER_PASS
- - run:
- name: Build from dockerfile
- command: |
- TAG=edge make build
- - run:
- name: Push to docker hub
- command: |
- TAG=edge make push
-
-# Orchestrate our job run sequence
-workflows:
- build_and_test:
- jobs:
- - build
- - test
\ No newline at end of file
-# syntax=docker/dockerfile:1
-FROM --platform=$BUILDPLATFORM tonistiigi/xx:master AS xx
-FROM --platform=$BUILDPLATFORM rust:alpine as rbuild
-RUN apk add clang lld protobuf protobuf-dev git build-base mingw-w64-gcc
-COPY . .
-COPY --from=xx / /
+FROM rust AS chef
+USER root
+COPY .cargo .cargo
+RUN cargo install cargo-chef
+RUN apt-get update && apt-get install -y protobuf-compiler
+WORKDIR /app
-ARG TARGETPLATFORM
-RUN xx-cargo build --release --target-dir ./build
+# Planning install
+FROM chef AS planner
+COPY . .
+RUN cargo chef prepare --recipe-path recipe.json
-FROM --platform=$BUILDPLATFORM alpine as passwd
-RUN addgroup -S nova && adduser -S nova -G nova
+# Building all targets
+FROM chef AS builder
+COPY --from=planner /app/recipe.json recipe.json
-FROM --platform=$BUILDPLATFORM golang:alpine as gbuild
-RUN apk add clang lld
-COPY --from=xx / /
-ARG TARGETPLATFORM
-COPY --from=rbuild /build/release/liball_in_one.a ./build/lib/liball_in_one.a
+# Notice that we are specifying the --target flag!
+RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
-RUN go build -a -ldflags '-s' -o build/bin/nova cmd/nova/nova.go
+RUN cargo build --release
+# Base os
+FROM debian:latest AS runtime-base
+# RUN addgroup -S nova && adduser -S nova -G nova
+RUN apt-get update && apt-get install ca-certificates -y
-FROM scratch as component
-COPY --from=passwd /etc/passwd /etc/passwd
+# Final os
+FROM runtime-base AS runtime
ARG COMPONENT
ENV COMPONENT=${COMPONENT}
-COPY --from=rbuild /build/release/${COMPONENT} /usr/local/bin/
-USER nova
+COPY --from=builder /app/target/release/${COMPONENT} /usr/local/bin/
+# USER nova
ENTRYPOINT /usr/local/bin/${COMPONENT}
-
-FROM scratch as all_in_one
EXTENSION += .exe
endif
PROJECTS = $(shell find exes/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n')
-PLATFORMS :=
-ifdef BUILDX_PLATFORMS
- PLATFORMS += --platform ${BUILDX_PLATFORMS}
-endif
# Static libraries
target/release/lib%.a: libs/%
@mkdir -p build/bin
go build -a -ldflags '-s' -o build/bin/nova cmd/nova/nova.go
-docker-%:
-
-
-docker: $(PROJECTS:%=docker-%)
BINS=$(PROJECTS:%=build/bin/%$(EXTENSION))
-bins: $(BINS) build/bin/nova$(EXTENSION)
-
-all: docker bins
+all: $(BINS) build/bin/nova$(EXTENSION)
clean:
rm -rf build
rm -rf $(PROJECTS:%=target/release/%$(EXTENSION))
- rm -rf target/release/liball_in_one.a
+ rm -rf target/release/liball_in_one.a
test:
cargo test
-use std::{error::Error, future::IntoFuture};
+use std::{error::Error, future::Future, pin::Pin};
-use async_nats::Subscriber;
+use async_nats::{Client, Subscriber};
use managers::{
automoderation::Automoderation, bans::Bans, channels::Channels,
guild_schedules::GuildSchedules, guilds::Guilds, integrations::Integrations, invites::Invites,
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
let settings: Settings<CacheConfiguration> = Settings::new("cache").unwrap();
info!("loaded configuration: {:?}", settings);
- let nats = settings.nats.into_future().await?;
+ let nats =
+ Into::<Pin<Box<dyn Future<Output = anyhow::Result<Client>> + Send>>>::into(settings.nats)
+ .await?;
let mut cache = Cache::default();
config::Settings,
payloads::{CachePayload, DispatchEventTagged},
};
-use std::{convert::TryFrom, future::IntoFuture, str::FromStr};
+use std::{convert::TryFrom, future::Future, pin::Pin, str::FromStr};
use tokio::{select, sync::oneshot};
use tokio_stream::StreamExt;
use tracing_opentelemetry::OpenTelemetrySpanExt;
.shard(settings.shard, settings.shard_total)?
.build();
- let nats = settings.nats.into_future().await?;
+ let nats = Into::<Pin<Box<dyn Future<Output = anyhow::Result<Client>> + Send>>>::into(
+ settings.nats,
+ )
+ .await?;
shard.start().await?;
loop {
use grpc::RLServer;
use leash::{AnyhowResultFuture, Component};
use proto::nova::ratelimit::ratelimiter::ratelimiter_server::RatelimiterServer;
+use redis::aio::MultiplexedConnection;
use shared::config::Settings;
-use std::future::IntoFuture;
+use std::future::Future;
+use std::pin::Pin;
use tokio::sync::oneshot;
use tonic::transport::Server;
) -> AnyhowResultFuture<()> {
Box::pin(async move {
let listening_address = settings.server.listening_adress;
- let redis = settings.redis.into_future().await?;
+ let redis = Into::<
+ Pin<Box<dyn Future<Output = anyhow::Result<MultiplexedConnection>> + Send>>,
+ >::into(settings.redis)
+ .await?;
let server = RLServer::new(RedisLock::new(redis));
mod config;
mod handler;
-use std::future::IntoFuture;
+use std::{future::Future, pin::Pin};
use crate::{
config::Webhook,
handler::{make_service::MakeSvc, WebhookService},
};
+use async_nats::Client;
use hyper::Server;
use leash::{AnyhowResultFuture, Component};
use shared::config::Settings;
let bind = settings.server.listening_adress;
info!("Nats connected!");
- let nats = settings.nats.into_future().await?;
+ let nats = Into::<Pin<Box<dyn Future<Output = anyhow::Result<Client>> + Send>>>::into(
+ settings.nats,
+ )
+ .await?;
let make_service = MakeSvc::new(WebhookService {
config: settings.config,
-use std::{
- future::{Future, IntoFuture},
- pin::Pin,
-};
+use std::{future::Future, pin::Pin};
use async_nats::Client;
use serde::Deserialize;
pub host: String,
}
-impl IntoFuture for Configuration {
- type Output = anyhow::Result<Client>;
-
- type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
-
- fn into_future(self) -> Self::IntoFuture {
- Box::pin(async move { Ok(async_nats::connect(self.host).await?) })
+impl From<Configuration> for Pin<Box<dyn Future<Output = anyhow::Result<Client>> + Send>> {
+ fn from(value: Configuration) -> Self {
+ Box::pin(async move { Ok(async_nats::connect(value.host).await?) })
}
}
use redis::{aio::MultiplexedConnection, Client};
use serde::Deserialize;
-use std::{
- future::{Future, IntoFuture},
- pin::Pin,
-};
+use std::{future::Future, pin::Pin};
#[derive(Clone, Debug, Deserialize)]
pub struct Configuration {
pub url: String,
}
-impl IntoFuture for Configuration {
- type Output = anyhow::Result<MultiplexedConnection>;
- type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + Send>>;
-
- fn into_future(self) -> Self::IntoFuture {
+impl From<Configuration>
+ for Pin<Box<dyn Future<Output = anyhow::Result<MultiplexedConnection>> + Send>>
+{
+ fn from(value: Configuration) -> Self {
Box::pin(async move {
- let con = Client::open(self.url)?;
+ let con = Client::open(value.url)?;
let (multiplex, ready) = con.create_multiplexed_tokio_connection().await?;
tokio::spawn(ready);