diff --git a/.dockerignore b/.dockerignore index c4ffae9..c1c56b3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,9 @@ downloads/ +download/ +.git/ +.github/ +.forgejo/ +.idea/ +.DS_Store +*.md +media-roller diff --git a/Dockerfile b/Dockerfile old mode 100755 new mode 100644 index 093f5b0..54caa21 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ -FROM golang:1.25.3-alpine3.22 AS builder +# syntax=docker/dockerfile:1 +FROM --platform=$BUILDPLATFORM golang:1.25.3-alpine3.22 AS builder +ARG TARGETOS +ARG TARGETARCH RUN apk add --no-cache curl WORKDIR /app @@ -10,10 +13,16 @@ COPY go.mod go.mod COPY go.sum go.sum RUN go mod download -RUN go build -x -o media-roller ./src +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -x -o media-roller ./src # yt-dlp needs python -FROM python:3.13.7-alpine3.22 +FROM --platform=$TARGETPLATFORM python:3.13.7-alpine3.22 + +ARG TARGETARCH + +LABEL org.opencontainers.image.source="https://git.khoavo.myds.me/vndangkhoa/kv-download" +LABEL org.opencontainers.image.description="Media Roller - Mobile friendly video downloader" +LABEL org.opencontainers.image.licenses="MIT" # This is where the downloaded files will be saved in the container. ENV MR_DOWNLOAD_DIR="/download" @@ -47,4 +56,7 @@ RUN yt-dlp --version && \ EXPOSE 9292 +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:9292/ || exit 1 + ENTRYPOINT ["/app/media-roller"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e2a54ef --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +services: + kv-download: + image: git.khoavo.myds.me/vndangkhoa/kv-download:latest + container_name: kv-download + restart: unless-stopped + ports: + - "9292:9292" + volumes: + - ./downloads:/download + environment: + - MR_DOWNLOAD_DIR=/download + - TZ=Asia/Ho_Chi_Minh + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:9292/"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 5s + deploy: + resources: + limits: + memory: 1G + cpus: "1.0" + logging: + driver: json-file + options: + max-size: "10m" + max-file: "3"