Skip to content
This repository was archived by the owner on Jan 13, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:8-alpine

ENV APPLE_MUSIC_TOKEN=""

EXPOSE 5000

ADD . /code

WORKDIR /code

RUN npm install

RUN npm install -g serve @angular/cli

RUN apk add --update bash sed && rm -rf /var/cache/apk/*

RUN chmod u+x build.sh run.sh

RUN ng build --prod --aot

RUN cd ./dist/apple-music-web-player && ls -la

CMD ["/bin/bash","/code/run.sh"]
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,24 @@ A Progressive Web App for Apple Music built with Angular, Angular Material, and
Replace `APPLE_MUSIC_TOKEN` in [`environment.ts`](src/environments/environment.ts) with your own [developer token](https://developer.apple.com/documentation/applemusicapi/getting_keys_and_creating_tokens).

Run `ng serve --aot` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.


## Running With Docker

First you must install [Docker CE](https://docs.docker.com/install/) at least version 16.04.

Then you must build your image running inside the app folder the following CMD:

```bash
docker build -t applemusicplayer:latest .
```

To run the app just type:

```bash
docker run -p 5000:5000 -d -e APPLE_MUSIC_TOKEN="<YOUR_TOKEN>" applemusicplayer:latest
```

This command will start a web server running at http://localhost:5000

NOTE: please replace `<YOUR_TOKEN>` with your token for [MusicKit JS](https://developer.apple.com/documentation/musickitjs).
7 changes: 7 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
echo "Token: $APPLE_MUSIC_TOKEN"

sed -i "/onFetch(event) {/,/const req = event.request;/c onFetch(event){const req=event.request;const whitelist=['apple'];if(whitelist.some(word=>req.url.toLowerCase().includes(word.toLowerCase()))){return}" ./dist/apple-music-web-player/ngsw-worker.js
sed -i "s/APPLE_MUSIC_TOKEN/$APPLE_MUSIC_TOKEN/" ./dist/apple-music-web-player/main.*.js

serve -l tcp://0.0.0.0:5000