rewrite dockerfile / deployment

This commit is contained in:
2020-10-25 12:19:35 +01:00
parent 95bd2077ce
commit ac039233ea
2 changed files with 37 additions and 3 deletions

View File

@@ -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"]

23
deployment.yml Normal file
View File

@@ -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"