Skip to content

Commit

Permalink
fix(docker): properly set API tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
streambinder committed Jul 5, 2023
1 parent 966c9c7 commit d647f11
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
7 changes: 3 additions & 4 deletions lyrics/genius.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import (
"github.com/streambinder/spotitube/util"
)

const (
contextValueLabelMainArtist = "mainArtistOnly"
fallbackGeniusToken = ""
)
const contextValueLabelMainArtist = "mainArtistOnly"

var fallbackGeniusToken = ""

type contextValueLabel string

Expand Down
12 changes: 6 additions & 6 deletions spotify/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ import (
)

const (
TokenBasename = "session.json"
closeTabHTML = "<!DOCTYPE html><html><head><script>open(location, '_self').close();</script></head></html>"
fallbackSpotifyID = ""
fallbackSpotifyKey = ""
TokenBasename = "session.json"
closeTabHTML = "<!DOCTYPE html><html><head><script>open(location, '_self').close();</script></head></html>"
)

var (
port = 65535
tokenPath = util.CacheFile(TokenBasename)
port = 65535
tokenPath = util.CacheFile(TokenBasename)
fallbackSpotifyID = ""
fallbackSpotifyKey = ""
)

type Client struct {
Expand Down
Binary file added spotitube
Binary file not shown.

0 comments on commit d647f11

Please sign in to comment.