Skip to content

Commit

Permalink
build(container): Restructure Containerfile to allow more flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
KirilMihaylov committed Aug 6, 2024
1 parent 2c80570 commit f88e155
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ COPY --chown="0":"0" --chmod="0555" "./src/" "/code/src/"

FROM compile-lib-base AS compile-application-base

ARG package

COPY --from=compile-lib-base --chown="0":"0" --chmod="0555" \
"/code/src/lib.rs" \
"/code/application/src/lib.rs"

ARG package

LABEL "package"="${package}"

COPY --chown="0":"0" --chmod="0555" \
"./${package}/Cargo.toml" \
"/code/application/Cargo.toml"
Expand All @@ -58,9 +60,13 @@ FROM compile-application-base AS compile-application

ARG package

COPY --chown="0":"0" --chmod="0555" "./${package}/" "/code/application/"
LABEL "package"="${package}"

ARG profile="release"
ARG profile

LABEL "profile"="${profile}"

COPY --chown="0":"0" --chmod="0555" "./${package}/" "/code/application/"

RUN "cargo" \
"rustc" \
Expand All @@ -71,7 +77,7 @@ RUN "cargo" \
"--" \
"-C" "target-feature=+crt-static"

FROM gcr.io/distroless/static:latest AS service
FROM gcr.io/distroless/static:latest AS service-base

VOLUME ["/service/logs/"]

Expand All @@ -90,12 +96,13 @@ ENV GAS_FEE_CONF__GAS_PRICE_DENOMINATOR="400"
ENV GAS_FEE_CONF__FEE_ADJUSTMENT_NUMERATOR="5"
ENV GAS_FEE_CONF__FEE_ADJUSTMENT_DENOMINATOR="1"
ENV IDLE_DURATION_SECONDS="60"
ENV LOGS_DIRECTORY="/service/logs/"
ENV NODE_GRPC_URI="###"
ENV OUTPUT_JSON="0"
ENV SIGNING_KEY_MNEMONIC="###"
ENV TIMEOUT_DURATION_SECONDS="60"

FROM service AS alarms-dispatcher-base
FROM service-base AS alarms-dispatcher-base

ENV PRICE_ALARMS_GAS_LIMIT_PER_ALARM="500000"
ENV PRICE_ALARMS_MAX_ALARMS_GROUP="32"
Expand All @@ -104,22 +111,31 @@ ENV TIME_ALARMS_MAX_ALARMS_GROUP="32"

FROM alarms-dispatcher-base AS alarms-dispatcher

ARG profile_output_dir="release"
ARG profile_output_dir

COPY --from=compile-application --chown="0":"0" --chmod="0100" \
"/code/target/x86_64-unknown-linux-gnu/${profile_output_dir}/alarms-dispatcher" \
"./service"

FROM service AS market-data-feeder-base
FROM service-base AS market-data-feeder-base

ENV DURATION_BEFORE_START="600"
ENV GAS_LIMIT="###"
ENV UPDATE_CURRENCIES_INTERVAL_SECONDS="15"

FROM market-data-feeder-base AS market-data-feeder
ARG package
FROM ${package}-base AS service

ARG package

LABEL "package"="${package}"

ARG profile

LABEL "profile"="${profile}"

ARG profile_output_dir="release"
ARG profile_output_dir

COPY --from=compile-application --chown="0":"0" --chmod="0100" \
"/code/target/x86_64-unknown-linux-gnu/${profile_output_dir}/market-data-feeder" \
"/code/target/x86_64-unknown-linux-gnu/${profile_output_dir}/${package}" \
"./service"

0 comments on commit f88e155

Please sign in to comment.