From db07ed669b4205d02dd8494045b6fbfd0791c166 Mon Sep 17 00:00:00 2001 From: Kilerd Chan Date: Fri, 19 Apr 2019 17:06:30 +0800 Subject: [PATCH] feat: new docker support --- Cargo.toml | 1 + Dockerfile | 16 +++------------- Procfile | 2 -- Rocket.toml | 16 ---------------- RustConfig | 2 -- rust-toolchain | 1 - src/main.rs | 4 ++-- src/models/article.rs | 1 - 8 files changed, 6 insertions(+), 37 deletions(-) delete mode 100644 Procfile delete mode 100644 Rocket.toml delete mode 100644 RustConfig delete mode 100644 rust-toolchain diff --git a/Cargo.toml b/Cargo.toml index 565d6d2..2e23206 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,3 +28,4 @@ rand = "0.6.5" pretty_env_logger = "0.3.0" time = "0.1.42" rss = "1.7.0" +diesel_derives = "1.4.0" diff --git a/Dockerfile b/Dockerfile index 7a2ca2f..58d699a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,4 @@ -FROM clux/muslrust:nightly as builder - -RUN cargo install diesel_cli --no-default-features --features postgres -RUN mkdir -p /out && cp /root/.cargo/bin/diesel /out/ +FROM clux/muslrust:stable as builder COPY . /app WORKDIR /app @@ -10,20 +7,13 @@ RUN cargo build --release FROM alpine:latest -COPY --from=builder /out/diesel /bin/ - COPY --from=builder /app/migrations /application/migrations -COPY --from=builder /app/Rocket.toml /application/Rocket.toml -COPY --from=builder /app/Cargo.toml /application/Cargo.toml -COPY --from=builder /app/entrypoint.sh /application/entrypoint.sh -COPY --from=builder /app/static /application/static +COPY --from=builder /app/templates /application/templates COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/rubble /application/rubble EXPOSE 8000 -ENV ROCKET_ENV production -ENV ROCKET_SECRET_KEY 123456 ENV DATABASE_URL postgres://root@postgres/rubble WORKDIR /application -CMD ["sh", "./entrypoint.sh"] \ No newline at end of file +CMD ["./rubble"] \ No newline at end of file diff --git a/Procfile b/Procfile deleted file mode 100644 index c9a8970..0000000 --- a/Procfile +++ /dev/null @@ -1,2 +0,0 @@ -web: ROCKET_PORT=$PORT ROCKET_SECRET_KEY=$SECRET_KEY ./target/release/rubble -release: ./target/release/diesel migration run \ No newline at end of file diff --git a/Rocket.toml b/Rocket.toml deleted file mode 100644 index f7c2236..0000000 --- a/Rocket.toml +++ /dev/null @@ -1,16 +0,0 @@ -[global] -template_dir = "static" - -[development] -address = "localhost" -port = 8000 -workers = 1 -log = "normal" -secret_key = "JR7bWcbwRfF/+Kc3jKfgxPiuLFyUxMRgTyJlcruItA0=" -limits = { forms = 524288 } - -[production] -address = "0.0.0.0" -log = "critical" -port = 8000 -limits = { forms = 524288 } \ No newline at end of file diff --git a/RustConfig b/RustConfig deleted file mode 100644 index 04e74c3..0000000 --- a/RustConfig +++ /dev/null @@ -1,2 +0,0 @@ -RUST_INSTALL_DIESEL=1 -DIESEL_FLAGS="--no-default-features --features postgres" \ No newline at end of file diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 07ade69..0000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -nightly \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index bdc3ee6..67b2dac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,8 @@ -#![feature(proc_macro_hygiene, decl_macro, custom_attribute, plugin)] - #[macro_use] extern crate diesel; #[macro_use] +extern crate diesel_derives; +#[macro_use] extern crate diesel_migrations; use actix_web::{ diff --git a/src/models/article.rs b/src/models/article.rs index 932f175..65b0d95 100644 --- a/src/models/article.rs +++ b/src/models/article.rs @@ -10,7 +10,6 @@ use diesel::{Insertable, Queryable}; use serde::{Deserialize, Serialize}; #[derive(Queryable, Debug, Serialize)] -#[table_name = "articles"] pub struct Article { pub id: i32, pub title: String,