-
Notifications
You must be signed in to change notification settings - Fork 10
/
Dockerfile-sentry
96 lines (65 loc) · 2.96 KB
/
Dockerfile-sentry
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Builder
FROM rust:latest as builder
LABEL maintainer="[email protected]"
WORKDIR /usr/src/app
# A hack around the build step that will cache dependencies and make builds faster
RUN mkdir -p primitives/src/ adapter/src/ sentry/src/
COPY ./primitives/Cargo.toml ./primitives/Cargo.toml
# we also need to copy the examples otherwise we will get error for them
COPY ./primitives/examples ./primitives/examples
RUN touch ./primitives/src/lib.rs && echo "pub fn main() {println!(\"cargo:rerun-if-changed=\\\"/tmp/build.rs\\\"\");}" >> ./primitives/src/lib.rs
COPY ./adapter/Cargo.toml ./adapter/Cargo.toml
RUN touch ./adapter/src/lib.rs && echo "pub fn main() {println!(\"cargo:rerun-if-changed=\\\"/tmp/build.rs\\\"\");}" >> ./adapter/src/lib.rs
COPY ./sentry/Cargo.toml ./sentry/Cargo.toml
COPY ./sentry/src/bin ./sentry/src/bin
RUN touch ./sentry/src/main.rs && echo "fn main() {println!(\"cargo:rerun-if-changed=\\\"/tmp/build.rs\\\"\");}" >> ./sentry/src/main.rs
COPY ./Cargo.lock ./Cargo.lock
RUN touch Cargo.toml && echo "[workspace]\n members = [ 'primitives', 'adapter', 'sentry' ]" >> Cargo.toml
RUN cargo build -p sentry --bin sentry --release
# remove the not needed build artifacts
RUN rm -f target/release/deps/sentry*
RUN rm -f target/release/deps/adapter*
RUN rm -f target/release/deps/primitives*
RUN rm -f target/release/deps/libadapter*
RUN rm -f target/release/deps/libprimitives*
COPY . .
# We install the sentry binary with all features in Release mode
# Include the full backtrace for easier debugging
RUN RUST_BACKTRACE=full cargo install --locked --path sentry --bin sentry --all-features
WORKDIR /usr/local/bin
RUN cp $CARGO_HOME/bin/sentry .
FROM ubuntu:20.04
RUN apt update && apt-get install -y libssl-dev ca-certificates
# `production` or `development` - default: `development`
ENV ENV=
# Redis URL - default: `redis://127.0.0.1:6379`
ENV READIS_URL=
# The IP address on which the sentry server will be listening - default: `0.0.0.0`
ENV IP_ADDR=
# The Port on which the sentry server will be listening - default: `8005`
ENV PORT=
# `ethereum` or `dummy`
ENV ADAPTER=
# only applicable if you use the `--adapter ethereum`
ENV KEYSTORE_FILE=
ENV KEYSTORE_PWD=
# Only applicable if you use the `--adapter dummy`
ENV DUMMY_IDENTITY=
# To setup TLS supply both `PRIVATE_KEYS` & `CERTIFICATES`
# Otherwise you will get an error
ENV PRIVATE_KEYS=
ENV CERTIFICATES=
# If set it will override the configuration file used
ENV CONFIG=
WORKDIR /usr/local/bin
COPY docs/config/cloudflare_origin.crt /usr/local/share/ca-certificates/
RUN update-ca-certificates
COPY ./scripts/sentry-docker ./scripts/sentry-docker
COPY --from=builder /usr/local/bin/sentry .
ENTRYPOINT ["./scripts/sentry-docker/entrypoint.sh"]
CMD sentry -a ${ADAPTER:-ethereum} \
${KEYSTORE_FILE:+-k $KEYSTORE_FILE} \
${DUMMY_IDENTITY:+-i $DUMMY_IDENTITY} \
${PRIVATE_KEYS:+--privateKeys $PRIVATE_KEYS} \
${CERTIFICATES:+--certificates $CERTIFICATES} \
${CONFIG}