-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
56 lines (41 loc) · 1.72 KB
/
Dockerfile
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
# Build image
# Note that it is important which debian image is used, because not all of them have a
# recent enough version of protobuf-compiler
FROM rust:1-bookworm AS build
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y cmake pkg-config libssl-dev librdkafka-dev protobuf-compiler
RUN USER=root cargo new --bin taskbroker
WORKDIR /taskbroker
ARG config_file=config-sentry-dev.yaml
# All these files are required to build or run the application
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
COPY ./migrations ./migrations
COPY ./config/${config_file} ./config.yaml
# This is set by the cloudbuild.yaml file
ARG TASKWORKER_GIT_REVISION=""
ENV TASKWORKER_GIT_REVISION=${TASKWORKER_GIT_REVISION}
# Build dependencies in a way they can be cached
RUN cargo build --release
RUN rm src/*.rs
# Copy source tree
COPY ./src ./src
# Build the main binary
RUN rm ./target/release/deps/taskbroker*
RUN cargo build --release
RUN echo "${TASKWORKER_GIT_REVISION}" > ./.VERSION
# Runtime image
FROM debian:bookworm-slim
# Necessary fot libssl bindings
RUN apt-get update && apt-get upgrade -y && apt-get install -y libssl-dev
EXPOSE 50051
# For the sqlite to be mounted too
RUN mkdir /opt/sqlite
# Import the built binary and config file and run it
COPY --from=build /taskbroker/.VERSION /opt/.VERSION
COPY --from=build /taskbroker/config.yaml /opt/config.yaml
COPY --from=build /taskbroker/target/release/taskbroker /opt/taskbroker
ENTRYPOINT ["/opt/taskbroker"]
CMD ["--config", "/opt/config.yaml"]
# To build and run locally:
# docker build -t taskbroker --no-cache . && docker rm taskbroker && docker run --name taskbroker -p 127.0.0.1:50051:50051 -e TASKBROKER_KAFKA_CLUSTER=sentry_kafka:9093 --network sentry taskbroker