-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (59 loc) · 2.5 KB
/
Dockerfile
File metadata and controls
73 lines (59 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Multi-stage build for AudioMuse All-in-One container
# STAGE 1: Get source files from local directory
FROM alpine:latest AS source-fetcher
WORKDIR /src
# Copy local files instead of git clone
COPY . ./AudioMuse-AI-MusicServer
# STAGE 2: Build Go Backend for Music Server
FROM golang:1.25-bookworm AS backend-builder
WORKDIR /src
COPY --from=source-fetcher /src/AudioMuse-AI-MusicServer .
WORKDIR /src/music-server-backend
# dependencies are tracked in go.mod/go.sum, so just download them
RUN go mod download
RUN CGO_ENABLED=1 go build -tags "fts5" -o music-server .
# STAGE 3: Build React Frontend for Music Server
# Use bookworm to stay consistent with backend-builder and avoid libc mismatches
FROM node:20-bookworm AS frontend-builder
WORKDIR /src
COPY --from=source-fetcher /src/AudioMuse-AI-MusicServer .
WORKDIR /src/music-server-frontend
ARG REACT_APP_API_URL
ENV REACT_APP_API_URL=${REACT_APP_API_URL}
RUN npm install
RUN npm run build
# STAGE 4: Final runtime image
# runtime must have at least the same libc version as the Go build stage
FROM node:20-bookworm
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies and a lightweight static server for the frontend
RUN apt-get update && apt-get install -y --no-install-recommends \
supervisor \
sqlite3 \
curl \
bash \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Install 'serve' globally to serve the built frontend
RUN npm install -g serve@14.1.2
# Create application directory
WORKDIR /app
# Copy built Go backend
COPY --from=backend-builder /src/music-server-backend/music-server ./music-server
RUN chmod +x ./music-server
# Copy React frontend source and dependencies
# Copy only the built frontend (static files)
COPY --from=frontend-builder /src/music-server-frontend/build ./music-server-frontend/build
# Ensure a /favicon.ico exists in the build by copying the PNG if ICO is missing
RUN if [ -f /app/music-server-frontend/build/audiomuseai.png ] && [ ! -f /app/music-server-frontend/build/favicon.ico ]; then cp /app/music-server-frontend/build/audiomuseai.png /app/music-server-frontend/build/favicon.ico; fi
# Copy configurations and startup script
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Create necessary directories
RUN mkdir -p /var/log/supervisor \
&& mkdir -p /config
# Expose ports
EXPOSE 3000 8080
# Use supervisor to manage multiple processes
ENTRYPOINT ["/entrypoint.sh"]