diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6e19512 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.dockerignore +Dockerfile diff --git a/.gitignore b/.gitignore index aafeace..33a346d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ .DS_Store # Environment variables -.env \ No newline at end of file +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..94128c8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +# syntax=docker/dockerfile:1 + +FROM python:latest + +WORKDIR /api + +COPY requirements.txt requirements.txt +RUN pip3 install -r requirements.txt + +COPY api/ . + +CMD [ "python3", "spotify.py"] diff --git a/SetUp.md b/SetUp.md index 4e43c1a..e2259f1 100644 --- a/SetUp.md +++ b/SetUp.md @@ -43,6 +43,28 @@ curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Authorizat * Deploy! +## Run locally with Docker + +* You need to have [Docker](https://docs.docker.com/get-docker/) installed. + +* Add Environment Variables: + * `SPOTIFY_REFRESH_TOKEN` + * `SPOTIFY_CLIENT_ID` + * `SPOTIFY_SECRET_ID` + +* To run the service, open a terminal in the root folder of the repo:
+ Execute: + ``` + docker compose up + ``` +* When finished, navigate to [http://localhost:5000/](http://localhost:5000/) + +* To stop the service, open a terminal in the root folder of the repo:
+ Execute: + ``` + docker compose down + ``` + ## ReadMe You can now use the following in your readme: diff --git a/api/spotify.py b/api/spotify.py index b36d4c2..c4c3912 100644 --- a/api/spotify.py +++ b/api/spotify.py @@ -153,4 +153,4 @@ def catch_all(path): if __name__ == "__main__": - app.run(debug=True) + app.run(host="0.0.0.0", debug=True) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5d7a9d4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.8' +services: + spotify-readme: + build: . + ports: + - "5000:5000" + volumes: + - ./api:/api +volumes: + persistent: diff --git a/api/requirements.txt b/requirements.txt similarity index 100% rename from api/requirements.txt rename to requirements.txt