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
Dockerize Medea #35
Merged
Merged
Dockerize Medea #35
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ec80b4d
Dockerfile, Makefile
alexlapa 7d47002
.dockerignore, improve build scripts
alexlapa fc86933
quickfix
alexlapa e1aaea4
extend conf with log
alexlapa a37b4db
reread
alexlapa 0cfe01f
reread
alexlapa d0ee004
Correct conf changes
tyranron d01eedb
Correct Dockerfile
tyranron f973f39
Correct Makefile, support MacOS
tyranron 7e6b8f6
Impl post-push Docker Hub hook
tyranron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've refactored this to support macOS.