Added support for Docker

- Updated SetUp.md with a "Run locally with Docker" section
- Moved requirements.txt to the root of the repo since some hosting
  services require the file to be there (eg. Heroku https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-python)
This commit is contained in:
AlexandrosAlexiou
2021-11-30 21:31:48 +02:00
committed by Andrew Novac
parent 0bf396a69f
commit 02b606b543
7 changed files with 48 additions and 2 deletions

2
.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
.dockerignore
Dockerfile

2
.gitignore vendored
View File

@@ -2,4 +2,4 @@
.DS_Store
# Environment variables
.env
.env

12
Dockerfile Normal file
View File

@@ -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"]

View File

@@ -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: <br>
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: <br>
Execute:
```
docker compose down
```
## ReadMe
You can now use the following in your readme:

View File

@@ -153,4 +153,4 @@ def catch_all(path):
if __name__ == "__main__":
app.run(debug=True)
app.run(host="0.0.0.0", debug=True)

10
docker-compose.yml Normal file
View File

@@ -0,0 +1,10 @@
version: '3.8'
services:
spotify-readme:
build: .
ports:
- "5000:5000"
volumes:
- ./api:/api
volumes:
persistent: