From ac039233ea93b20bf956b7661b521fc1bf4ac871 Mon Sep 17 00:00:00 2001 From: Jur van den Berg Date: Sun, 25 Oct 2020 12:19:35 +0100 Subject: [PATCH] rewrite dockerfile / deployment --- Dockerfile | 17 ++++++++++++++--- deployment.yml | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 deployment.yml diff --git a/Dockerfile b/Dockerfile index 4f476d3..fbf8b74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,21 @@ -FROM rust:1.43 as builder +FROM rust:1.47 as builder WORKDIR /usr/src/sarcastifybot + +# Avoid having to install/build all dependencies by copying +# the Cargo files and making a dummy src/main.rs +COPY Cargo.toml . +COPY Cargo.lock . +RUN mkdir -p src && echo "fn main() {}" > src/main.rs +RUN cargo build --release + +# We need to touch our real main.rs file or else docker will use +# the cached one. COPY . . -RUN cargo install --path . +RUN touch src/main.rs +RUN cargo build --release FROM debian:buster RUN apt-get update && apt-get install -y openssl ca-certificates -COPY --from=builder /usr/local/cargo/bin/sarcastifybot /usr/local/bin/sarcastifybot +COPY --from=builder /usr/src/sarcastifybot/target/release/sarcastifybot /usr/local/bin/sarcastifybot CMD ["sarcastifybot"] diff --git a/deployment.yml b/deployment.yml new file mode 100644 index 0000000..32689ac --- /dev/null +++ b/deployment.yml @@ -0,0 +1,23 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sarcastifybot + labels: + app: sarcastifybot +spec: + replicas: 1 + selector: + matchLabels: + app: sarcastifybot + template: + metadata: + labels: + app: sarcastifybot + spec: + containers: + - name: main + image: harbor.blacknova.io/nvls/sarcastifybot:latest + imagePullPolicy: Always + env: + - name: TELEGRAM_BOT_TOKEN + value: "924754197:AAGvpdqUY-2pOy1wnQIW2zeS-oA7-lxwfqU"