diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 2bfd08b..fafd190 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -91,10 +91,10 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - uses: docker/build-push-action@v4 with: - build-args: | - SPOTIFY_ID="${{ secrets.SPOTIFY_ID }}" - SPOTIFY_KEY="${{ secrets.SPOTIFY_KEY }}" - GENIUS_TOKEN="${{ secrets.GENIUS_TOKEN }}" + secrets: | + SPOTIFY_ID=${{ secrets.SPOTIFY_ID }} + SPOTIFY_KEY=${{ secrets.SPOTIFY_KEY }} + GENIUS_TOKEN=${{ secrets.GENIUS_TOKEN }} platforms: linux/amd64,linux/arm/v7,linux/arm64/v8 tags: ghcr.io/streambinder/spotitube:latest push: ${{ github.event_name != 'pull_request' }} diff --git a/Dockerfile b/Dockerfile index 8d9d50c..ee019db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,24 @@ -FROM golang:alpine as builder +# docker run -it --rm -p 65535:65535/tcp -v ~/Music:/data -v ~/.cache:/cache ghcr.io/streambinder/spotitubeFROM golang:alpine as builder WORKDIR /workspace -COPY go.mod . -COPY go.sum . +COPY . . RUN go mod download # git is garble runtime dependency # https://github.com/bluekeyes/go-gitdiff/issues/30 RUN apk add --no-cache git RUN go install mvdan.cc/garble@latest -COPY . . -RUN sed -iE "s/(fallbackSpotifyID += +)\"\"$/\1\"$SPOTIFY_ID\"/g" spotify/auth.go -RUN sed -iE "s/(fallbackSpotifyKey += +)\"\"$/\1\"$SPOTIFY_KEY\"/g" spotify/auth.go -RUN sed -iE "s/(fallbackGeniusToken += +)\"\"$/\1\"$GENIUS_TOKEN\"/g" lyrics/genius.go -RUN garble -literals -tiny -seed=random build +RUN --mount=type=secret,id=SPOTIFY_ID \ + --mount=type=secret,id=SPOTIFY_KEY \ + --mount=type=secret,id=GENIUS_TOKEN \ + garble -literals -tiny -seed=random build -ldflags="-X github.com/streambinder/spotitube/spotify.fallbackSpotifyID=$(cat /run/secrets/SPOTIFY_ID) -X github.com/streambinder/spotitube/spotify.fallbackSpotifyKey=$(cat /run/secrets/SPOTIFY_KEY) -X github.com/streambinder/spotitube/lyrics.fallbackGeniusToken=$(cat /run/secrets/GENIUS_TOKEN)" FROM alpine:latest RUN apk add --no-cache ffmpeg yt-dlp RUN mkdir /data +RUN mkdir /cache WORKDIR /data ENV XDG_MUSIC_DIR=/data +ENV XDG_CACHE_HOME=/cache COPY --from=builder /workspace/spotitube /usr/sbin/ +EXPOSE 65535/tcp ENTRYPOINT ["/usr/sbin/spotitube"] LABEL org.opencontainers.image.source=https://github.com/streambinder/spotitube diff --git a/lyrics/genius.go b/lyrics/genius.go index ffb6fab..534fc17 100644 --- a/lyrics/genius.go +++ b/lyrics/genius.go @@ -18,10 +18,9 @@ import ( "github.com/streambinder/spotitube/util" ) -const ( - contextValueLabelMainArtist = "mainArtistOnly" - fallbackGeniusToken = "" -) +const contextValueLabelMainArtist = "mainArtistOnly" + +var fallbackGeniusToken = "" type contextValueLabel string diff --git a/spotify/auth.go b/spotify/auth.go index bd09ff9..de47ab2 100644 --- a/spotify/auth.go +++ b/spotify/auth.go @@ -19,15 +19,15 @@ import ( ) const ( - TokenBasename = "session.json" - closeTabHTML = "" - fallbackSpotifyID = "" - fallbackSpotifyKey = "" + TokenBasename = "session.json" + closeTabHTML = "" ) var ( - port = 65535 - tokenPath = util.CacheFile(TokenBasename) + port = 65535 + tokenPath = util.CacheFile(TokenBasename) + fallbackSpotifyID = "" + fallbackSpotifyKey = "" ) type Client struct { diff --git a/spotitube b/spotitube new file mode 100755 index 0000000..dfeae34 Binary files /dev/null and b/spotitube differ