Initial docker setup using rust-musl-builder
Not working yet because sqlx 0.3 doesn't have an offline mode
This commit is contained in:
parent
377a260a2f
commit
1a1806ffc3
@ -1,15 +0,0 @@
|
|||||||
# NOTE: For maximum performance, build using a nightly compiler
|
|
||||||
# If you are using rust stable, remove the "-Zshare-generics=y" below.
|
|
||||||
|
|
||||||
[target.x86_64-unknown-linux-gnu]
|
|
||||||
linker = "/usr/bin/clang"
|
|
||||||
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Zshare-generics=y"]
|
|
||||||
|
|
||||||
[target.x86_64-apple-darwin]
|
|
||||||
rustflags = ["-Zshare-generics=y"]
|
|
||||||
|
|
||||||
# NOTE: you must manually install lld on windows. you can easily do this with the "scoop" package manager:
|
|
||||||
# `scoop install llvm`
|
|
||||||
[target.x86_64-pc-windows-msvc]
|
|
||||||
linker = "lld-link.exe"
|
|
||||||
rustflags = ["-Clinker=lld", "-Zshare-generics=y"]
|
|
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
target
|
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -147,6 +147,7 @@ dependencies = [
|
|||||||
"listenfd",
|
"listenfd",
|
||||||
"lru",
|
"lru",
|
||||||
"mime",
|
"mime",
|
||||||
|
"openssl-probe",
|
||||||
"seahash",
|
"seahash",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -16,6 +16,7 @@ hyper = "0.13"
|
|||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
listenfd = "0.3"
|
listenfd = "0.3"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
|
openssl-probe = "0.1"
|
||||||
tokio = { version = "0.2", features = ["macros", "rt-threaded", "sync"] }
|
tokio = { version = "0.2", features = ["macros", "rt-threaded", "sync"] }
|
||||||
sqlx = { version = "0.3", default-features = false, features = [ "runtime-tokio", "macros", "postgres", "chrono", "uuid", "ipnetwork", "json" ] }
|
sqlx = { version = "0.3", default-features = false, features = [ "runtime-tokio", "macros", "postgres", "chrono", "uuid", "ipnetwork", "json" ] }
|
||||||
warp = { version = "0.2", features = ["compression"] }
|
warp = { version = "0.2", features = ["compression"] }
|
||||||
|
22
Dockerfile
Normal file
22
Dockerfile
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# -*- mode: dockerfile -*-
|
||||||
|
|
||||||
|
# You can override this `--build-arg BASE_IMAGE=...` to use different
|
||||||
|
# version of Rust or OpenSSL.
|
||||||
|
ARG BASE_IMAGE=ekidd/rust-musl-builder:nightly-2020-10-08
|
||||||
|
|
||||||
|
# Our first FROM statement declares the build environment.
|
||||||
|
FROM ${BASE_IMAGE} AS builder
|
||||||
|
|
||||||
|
# Add our source code.
|
||||||
|
ADD --chown=rust:rust . ./
|
||||||
|
|
||||||
|
# Build our application.
|
||||||
|
RUN cargo build --release
|
||||||
|
|
||||||
|
# Now, we need to build our _real_ Docker container, copying in `using-sqlx`.
|
||||||
|
FROM alpine:latest
|
||||||
|
RUN apk --no-cache add ca-certificates
|
||||||
|
COPY --from=builder \
|
||||||
|
/home/rust/src/target/x86_64-unknown-linux-musl/release/bazaar_realm_api \
|
||||||
|
/usr/local/bin/
|
||||||
|
CMD /usr/local/bin/bazaar_realm_api
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
version: "2.0"
|
||||||
|
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build: .
|
||||||
|
volumes:
|
||||||
|
- cargo:/home/rust/.cargo
|
||||||
|
- target:/home/rust/src/target
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
cargo: {}
|
||||||
|
target: {}
|
@ -60,6 +60,7 @@ where
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
|
openssl_probe::init_ssl_cert_env_vars();
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
let env_log_filter =
|
let env_log_filter =
|
||||||
env::var("RUST_LOG").unwrap_or_else(|_| "warp=info,bazaar_realm_api=info".to_owned());
|
env::var("RUST_LOG").unwrap_or_else(|_| "warp=info,bazaar_realm_api=info".to_owned());
|
||||||
|
Loading…
Reference in New Issue
Block a user