ptth/Dockerfile

41 lines
1.0 KiB
Docker
Raw Normal View History

2020-11-02 18:02:01 +00:00
FROM rust:1.47-slim-buster as build
WORKDIR /usr/src
RUN apt-get update \
&& apt-get install -y git pkg-config libssl-dev
2020-11-02 18:02:01 +00:00
# Make sure the dependencies are all cached so we won't hammer crates.io
ADD old-git.tar.gz .
2020-11-27 01:07:39 +00:00
RUN git checkout bbb88c01e8ad28d256c8faf316f46d7214184ec2 \
2020-11-02 18:02:01 +00:00
&& git reset --hard \
2020-11-27 01:07:39 +00:00
&& cargo check -p ptth_relay
2020-11-02 18:02:01 +00:00
2020-11-27 01:07:39 +00:00
RUN cargo test --release --all \
&& cargo build --release -p ptth_relay
2020-11-02 18:02:01 +00:00
COPY .git .git
ARG gitcommithash=HEAD
RUN git checkout "$gitcommithash" \
&& git reset --hard \
2020-11-02 18:39:19 +00:00
&& echo "pub const GIT_VERSION: Option <&str> = Some (\"$(git rev-parse HEAD)\");" > src/git_version.rs \
2020-11-27 01:07:39 +00:00
&& cargo test --release --all \
&& cargo build --release -p ptth_relay
2020-11-02 18:02:01 +00:00
FROM debian:buster-slim as deploy
RUN apt-get update \
&& apt-get install -y libssl1.1 ca-certificates \
2020-11-02 18:39:19 +00:00
&& apt-get upgrade -y
2020-11-02 18:02:01 +00:00
COPY --from=build /usr/src/target/release/ptth_relay /root
2020-11-02 18:39:19 +00:00
COPY --from=build /usr/src/src/git_version.rs /root/git_version.rs
2020-11-27 01:07:39 +00:00
COPY --from=build /usr/src/handlebars /root/handlebars
2020-11-02 18:02:01 +00:00
WORKDIR /root
CMD ["./ptth_relay"]