🐳 Work on Docker build

main
_ 2020-11-02 18:02:01 +00:00
parent 16984ddcd3
commit 04cfaf75e1
3 changed files with 42 additions and 0 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
/target

40
Dockerfile Normal file
View File

@ -0,0 +1,40 @@
FROM rust:1.47-slim-buster as build
WORKDIR /usr/src
RUN apt-get update \
&& apt-get install -y git pkg-config
# Make sure the dependencies are all cached so we won't hammer crates.io
ADD old-git.tar.gz .
RUN git checkout 16984ddcd3c9cdc04b2c4c3625eb83176c1b2dda \
&& git reset --hard \
&& cargo check
RUN cargo test --release \
&& cargo build --release --bin ptth_relay
COPY .git .git
ARG gitcommithash=HEAD
RUN git checkout "$gitcommithash" \
&& git reset --hard \
&& echo "pub const GIT_VERSION: &str = \"$(git-rev-parse HEAD)\";" > src/git_version.rs \
&& cargo test --release \
&& cargo build --release --bin ptth_relay
FROM debian:buster-slim as deploy
RUN apt-get update \
&& apt-get upgrade
COPY --from=build /usr/src/target/release/ptth_relay /root
COPY ptth_relay.toml /root/ptth_relay.toml
COPY --from=build /usr/src/git_version.rs /root/git_version.rs
WORKDIR /root
CMD ["./ptth_relay"]

1
make-old-git-tar.bash Normal file
View File

@ -0,0 +1 @@
tar -czf old-git.tar.gz .git