diff --git a/.gitignore b/.gitignore index d9ca3b9..6a69e23 100644 --- a/.gitignore +++ b/.gitignore @@ -167,3 +167,4 @@ go.work.sum seanime-*/ tag.file v*.tar.gz +DATA/ diff --git a/Dockerfile b/Dockerfile index 7aedc38..dd85914 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,11 @@ -ARG TAG +ARG VERSION=latest -FROM node:latest +# Prep Files +FROM alpine:latest as downloader +WORKDIR /src # Install dependencies -RUN apt-get update && apt-get install -y \ - curl \ - wget \ - build-essential \ - golang \ - && rm -rf /var/lib/apt/lists/* +RUN apk add --no-cache curl tar wget # Fetch the latest tag and download the source code RUN curl -s https://api.github.com/repos/5rahim/seanime/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' > tag.file && \ @@ -18,19 +15,44 @@ RUN curl -s https://api.github.com/repos/5rahim/seanime/releases/latest | grep ' rm ${TAG}.tar.gz tag.file && \ mv seanime-* seanime + +# Start web build +FROM node:18-alpine AS frontend-build + # Set working directory to the extracted source code -WORKDIR /seanime +WORKDIR /app/seanime-web + +# Copy source from downloader +COPY --from=downloader /src/seanime/seanime-web ./ # Build the web interface -RUN cd seanime-web && \ - npm install && \ +RUN npm install && \ npm run build && \ - mkdir -p ../web && \ - mv out/* ../web/ + mkdir -p /app/web && \ + cp -r out/* /app/web/ + +# Start backend build +FROM golang:1.24-alpine AS backend-build + +# set build root +WORKDIR /build + +# Copy needed files from previous stages +COPY --from=downloader /src/seanime /build +COPY --from=frontend-build /app/web /build/web # Build the server for Linux RUN go build -o seanime -trimpath -ldflags="-s -w" +# Complete the APP +FROM alpine:latest + +# Set root +WORKDIR /app + +# Copy preped builds +COPY --from=backend-build /build/seanime . + # Set up the data directory VOLUME /DATA @@ -38,4 +60,4 @@ VOLUME /DATA EXPOSE 43211 # Command to run the server -CMD ["./seanime"] +CMD ["/app/seanime", "--datadir", "/DATA"]