improve docker configs

This commit is contained in:
mykola2312 2024-02-29 20:41:00 +02:00
parent 17ecd681d8
commit 38d87ac70c
3 changed files with 27 additions and 10 deletions

View file

@ -1,24 +1,32 @@
# Rust build
FROM rust:1-alpine3.19
FROM rust:1-alpine3.19 AS builder
ENV RUSTFLAGS="-C target-feature=-crt-static"
RUN apk add --no-cache musl-dev openssl-dev
WORKDIR /app
COPY Cargo.toml Cargo.lock /app/
COPY src/ /app/src
WORKDIR /usr/src/app
RUN USER=root cargo init
COPY ./Cargo.toml .
COPY Cargo.lock .
COPY src/ ./src
COPY migrations ./migrations
RUN cargo build --release
RUN touch src/main.rs && cargo build --release
RUN strip target/release/mk-dl-bot
# Run
FROM alpine:3.19
FROM alpine:3.19 AS final
# Dependencies
RUN apk add --no-cache libgcc
RUN apk add --no-cache ffmpeg python3 py3-pip
RUN pip install --break-system-packages yt-dlp
WORKDIR /app
COPY migrations /app/
COPY --from=0 /app/target/release/mk-dl-bot /app/
# Those directories are required by bot
RUN mkdir -p /var/lib/mk-dl-bot
RUN mkdir -p /var/log/mk-dl-bot
ENTRYPOINT ["/mk-dl-bot"]
WORKDIR /app
COPY migrations ./migrations
COPY --from=builder /usr/src/app/target/release/mk-dl-bot .
ENTRYPOINT ["/app/mk-dl-bot"]

9
docker-compose-dev.yml Normal file
View file

@ -0,0 +1,9 @@
services:
mk-dl-bot:
build: .
env_file:
- .env
volumes:
- db:/var/lib/mk-dl-bot
volumes:
db: