From dee8e5c518c116441f90f7acd47daec3b4d6b389 Mon Sep 17 00:00:00 2001 From: Deluan Date: Wed, 22 Jan 2020 19:42:56 -0500 Subject: [PATCH] Initial docker support --- .dockerignore | 11 ++++++++++ Dockerfile | 53 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 16 ++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..56e62ecfc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.DS_Store +ui/node_modules +ui/build +Jamstash-master +Dockerfile +data +*.db +testDB +*_test.go +sonic-server +assets/*gen.go diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..5abf6f1ba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +##################################################### +### Build UI bundles +FROM node:12.14-alpine AS jsbuilder +WORKDIR /src +COPY ui/package.json ui/package-lock.json ./ +RUN npm ci +COPY ui/ . +RUN npm run build + + +##################################################### +### Build executable +FROM golang:1.13-alpine AS gobuilder + +# Download build tools +RUN mkdir -p /src/ui/build +RUN apk add -U --no-cache build-base git +RUN go get -u github.com/go-bindata/go-bindata/... + +# Download project dependencies +WORKDIR /src +COPY go.mod go.sum ./ +RUN go mod download + +# Copy source and UI bundle, build executable +COPY . . +COPY --from=jsbuilder /src/build/* /src/ui/build/ +COPY --from=jsbuilder /src/build/static/css/* /src/ui/build/static/css/ +COPY --from=jsbuilder /src/build/static/js/* /src/ui/build/static/js/ +RUN rm -rf /src/build/css /src/build/js +RUN make buildall + +# Download and unpack static ffmpeg +ARG FFMPEG_VERSION=4.1.4 +ARG FFMPEG_URL=https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-${FFMPEG_VERSION}-amd64-static.tar.xz +ADD ${FFMPEG_URL} /tmp/ffmpeg.tar.xz +RUN cd /tmp && tar xJf ffmpeg.tar.xz + + +##################################################### +### Build Final Image +FROM alpine +COPY --from=gobuilder /src/sonic-server /app/ +COPY --from=gobuilder /tmp/ffmpeg*/ffmpeg /usr/bin/ + +VOLUME ["/data", "/music"] +ENV SONIC_DBPATH /data/cloudsonic.db +ENV SONIC_MUSICFOLDER /music +ENV SONIC_LOGLEVEL info +EXPOSE 4533 + +WORKDIR /app +CMD "/app/sonic-server" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..8eab28b07 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +# This is just an example. Customize it to your needs. + +version: "3" +services: + cloudsonic: + build: . + ports: + - "4533:4533" + environment: + # See all options and defaults in conf/configuration.go + SONIC_PORT: 4533 + SONIC_SCANINTERVAL: 5s + SONIC_LOGLEVEL: debug + volumes: + - "./data:/data" + - "/Users/deluan/Music/iTunes/iTunes Media/Music:/music"