forked from cea-sec/openwec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 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,3 @@ | ||
/target | ||
/.vscode | ||
/.idea |
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,53 @@ | ||
FROM rust:slim-bookworm as chef | ||
RUN cargo install cargo-chef | ||
WORKDIR /SRC | ||
|
||
FROM chef AS planner | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM chef AS builder | ||
# Install system deps | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
clang \ | ||
libssl-dev \ | ||
libkrb5-dev \ | ||
make \ | ||
pkgconf | ||
|
||
COPY --from=planner /SRC/recipe.json recipe.json | ||
# Build dependencies - this is the caching Docker layer! | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
|
||
# Build application | ||
COPY . . | ||
RUN cargo build --release | ||
|
||
|
||
FROM debian:bookworm-slim | ||
ARG APP=/usr/src/openwec | ||
ARG DATA=/var/lib/openwec/data | ||
ARG DB=/var/lib/openwec/db | ||
|
||
EXPOSE 5985 | ||
ENV APP_USER=openwec | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
libgssapi-krb5-2 \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& groupadd $APP_USER \ | ||
&& useradd -g $APP_USER $APP_USER \ | ||
&& mkdir -p ${APP} ${DATA} ${DB} | ||
|
||
COPY --from=builder /SRC/target/release/openwec ${APP}/openwec | ||
COPY --from=builder /SRC/target/release/openwecd ${APP}/openwecd | ||
COPY ./docker/entrypoint.sh ${APP}/entrypoint.sh | ||
|
||
RUN chown -R $APP_USER:$APP_USER ${APP} ${DATA} ${DB} | ||
|
||
USER $APP_USER | ||
WORKDIR ${APP} | ||
|
||
CMD ["./entrypoint.sh"] |
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,15 @@ | ||
#!/bin/bash | ||
|
||
set -eux | ||
|
||
# Try to create openwec db if not already existing | ||
# This also applies migrations | ||
./openwec db init | ||
|
||
# Load subscriptions configuration files if provided | ||
if [ -d /etc/openwec.d/ ]; then | ||
./openwec subscriptions load /etc/openwec.d | ||
fi | ||
|
||
# Start openwecd | ||
exec ./openwecd |