This repository has been archived by the owner on Aug 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- impl instrumentisto/medea Docker image - add docker.build Makefile command Additionally: - add logging settings to config - upd 'rand' to 0.7 and 'slog' to 2.5
- Loading branch information
Showing
16 changed files
with
743 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
* | ||
|
||
# Medea sources and manifest. | ||
!Cargo.toml | ||
!Cargo.lock | ||
!src/ | ||
|
||
# Medea uses this sub-crates. | ||
!crates/ | ||
!proto/ | ||
|
||
# We don't need Jason while building Medea, but since it's in Medea's workspace, | ||
# Cargo should be able to see these files. | ||
!jason/Cargo.toml | ||
!jason/src/lib.rs | ||
|
||
# Medea dependencies cache. | ||
!.cache/cargo/ | ||
|
||
# !target/{mode} is added and removed dynamically to reduce image build times. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
RUST_LOG=debug | ||
MEDEA_CONF=config.toml | ||
|
||
COMPOSE_PROJECT_NAME=medea | ||
COMPOSE_IMAGE_NAME=instrumentisto/medea |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# | ||
# Stage 'dist' creates project distribution. | ||
# | ||
|
||
# https://hub.docker.com/_/rust | ||
ARG rust_ver=latest | ||
FROM rust:${rust_ver} AS dist | ||
ARG rustc_mode=release | ||
ARG rustc_opts=--release | ||
ARG cargo_home=/usr/local/cargo | ||
|
||
# Create user and group files, which will be used in a running container to | ||
# run the process as an unprivileged user. | ||
RUN mkdir -p /out/etc/ \ | ||
&& echo 'nobody:x:65534:65534:nobody:/:' > /out/etc/passwd \ | ||
&& echo 'nobody:x:65534:' > /out/etc/group | ||
|
||
COPY / /app/ | ||
|
||
# Build project distribution. | ||
RUN cd /app \ | ||
# Compile project. | ||
&& CARGO_HOME="${cargo_home}" \ | ||
# TODO: use --out-dir once stabilized | ||
# TODO: https://github.com/rust-lang/cargo/issues/6790 | ||
cargo build --bin=medea ${rustc_opts} \ | ||
# Prepare the binary and all dependent dynamic libraries. | ||
&& cp /app/target/${rustc_mode}/medea /out/medea \ | ||
&& ldd /out/medea \ | ||
| awk 'BEGIN{ORS=" "}$1~/^\//{print $1}$3~/^\//{print $3}' \ | ||
| sed 's/,$/\n/' \ | ||
| tr ' ' "\n" \ | ||
| xargs -I '{}' cp -fL --parents '{}' /out/ | ||
|
||
|
||
|
||
|
||
# | ||
# Stage 'runtime' creates final Docker image to use in runtime. | ||
# | ||
|
||
# https://hub.docker.com/_/scratch | ||
FROM scratch AS runtime | ||
|
||
COPY --from=dist /out/ / | ||
|
||
USER nobody:nobody | ||
|
||
ENTRYPOINT ["/medea"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# Docker Hub post-push hook that is responsible to tag built image properly. | ||
|
||
set -e | ||
|
||
# Parse image name and tag. | ||
tagStart=$(expr index "$IMAGE_NAME" :) | ||
repoName=${IMAGE_NAME:0:tagStart-1} | ||
origTag=${IMAGE_NAME:tagStart} | ||
|
||
# For full-versioned tag provide minor/major versions and 'latest' tags. | ||
if [[ "$origTag" == *"."*"."* ]]; then | ||
dot=$(expr index "$origTag" .) | ||
majorVer=${origTag:0:dot-1} | ||
|
||
rest=${origTag:dot} | ||
dot=$(expr index "$rest" .) | ||
minorVer="$majorVer.${rest:0:dot-1}" | ||
|
||
for tag in {"$minorVer","$majorVer",latest}; do | ||
docker tag $IMAGE_NAME ${repoName}:${tag} | ||
docker push ${repoName}:${tag} | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//! Logging settings. | ||
use std::str::FromStr as _; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use smart_default::SmartDefault; | ||
|
||
/// Logging settings. | ||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, SmartDefault)] | ||
#[serde(default)] | ||
pub struct Log { | ||
/// Maximum allowed level of application log entries. | ||
/// Defaults to `INFO`. | ||
#[default(String::from("INFO"))] | ||
pub level: String, | ||
} | ||
|
||
impl Log { | ||
/// Returns configured application logging level. `None` if disabled. | ||
pub fn level(&self) -> Option<slog::Level> { | ||
slog::Level::from_str(&self.level).ok() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.