2023-02-11 15:30:42 -05:00
|
|
|
FROM docker.io/library/rust:1-bookworm as builder
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y cmake protobuf-compiler \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2022-11-19 08:11:39 -05:00
|
|
|
RUN USER=root cargo install cargo-auditable
|
2021-12-11 17:46:42 -05:00
|
|
|
RUN USER=root cargo new --bin nostr-rs-relay
|
|
|
|
WORKDIR ./nostr-rs-relay
|
|
|
|
COPY ./Cargo.toml ./Cargo.toml
|
|
|
|
COPY ./Cargo.lock ./Cargo.lock
|
2022-11-19 08:11:39 -05:00
|
|
|
# build dependencies only (caching)
|
|
|
|
RUN cargo auditable build --release --locked
|
|
|
|
# get rid of starter project code
|
2021-12-11 17:46:42 -05:00
|
|
|
RUN rm src/*.rs
|
|
|
|
|
2022-11-19 08:11:39 -05:00
|
|
|
# copy project source code
|
2021-12-11 17:46:42 -05:00
|
|
|
COPY ./src ./src
|
2023-02-11 15:30:42 -05:00
|
|
|
COPY ./proto ./proto
|
|
|
|
COPY ./build.rs ./build.rs
|
2021-12-11 17:46:42 -05:00
|
|
|
|
2022-11-19 08:11:39 -05:00
|
|
|
# build auditable release using locked deps
|
2021-12-11 17:46:42 -05:00
|
|
|
RUN rm ./target/release/deps/nostr*relay*
|
2022-11-19 08:11:39 -05:00
|
|
|
RUN cargo auditable build --release --locked
|
2021-12-11 17:46:42 -05:00
|
|
|
|
2023-02-13 10:33:14 -05:00
|
|
|
FROM docker.io/library/debian:bookworm-slim
|
2022-11-05 14:24:17 -04:00
|
|
|
|
2021-12-11 17:46:42 -05:00
|
|
|
ARG APP=/usr/src/app
|
2021-12-11 23:18:05 -05:00
|
|
|
ARG APP_DATA=/usr/src/app/db
|
2021-12-11 17:46:42 -05:00
|
|
|
RUN apt-get update \
|
2023-02-11 14:57:53 -05:00
|
|
|
&& apt-get install -y ca-certificates tzdata sqlite3 libc6 \
|
2021-12-11 17:46:42 -05:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
EXPOSE 8080
|
|
|
|
|
|
|
|
ENV TZ=Etc/UTC \
|
|
|
|
APP_USER=appuser
|
|
|
|
|
|
|
|
RUN groupadd $APP_USER \
|
|
|
|
&& useradd -g $APP_USER $APP_USER \
|
2021-12-11 23:18:05 -05:00
|
|
|
&& mkdir -p ${APP} \
|
|
|
|
&& mkdir -p ${APP_DATA}
|
2021-12-11 17:46:42 -05:00
|
|
|
|
|
|
|
COPY --from=builder /nostr-rs-relay/target/release/nostr-rs-relay ${APP}/nostr-rs-relay
|
|
|
|
|
|
|
|
RUN chown -R $APP_USER:$APP_USER ${APP}
|
|
|
|
|
|
|
|
USER $APP_USER
|
2021-12-31 12:51:57 -05:00
|
|
|
WORKDIR ${APP}
|
2021-12-11 17:46:42 -05:00
|
|
|
|
2022-09-28 08:19:59 -04:00
|
|
|
ENV RUST_LOG=info,nostr_rs_relay=info
|
2021-12-31 15:05:11 -05:00
|
|
|
ENV APP_DATA=${APP_DATA}
|
|
|
|
|
|
|
|
CMD ./nostr-rs-relay --db ${APP_DATA}
|