Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] Basic Flask APP - flask Docker image - DockerCompose #2

Merged
merged 1 commit into from
Sep 9, 2024
Merged
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
2 changes: 2 additions & 0 deletions api/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MOVIE_API_HOST=0.0.0.0
MOVIE_API_PORT=5000
Empty file added api/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions api/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
""" Starts the Flask web app """
import os
from flask import Flask
from dotenv import load_dotenv


load_dotenv()
app = Flask(__name__)
app.url_map.strict_slashes = False
HOST = "0.0.0.0"
PORT = 5000


@app.route('/volumes')
def volume():
""" A dummy route to test volumes of docker"""
return "Testing volumes: -change me-"


if __name__ == "__main__":
if os.getenv("MOVIE_API_HOST"):
HOST = os.getenv("MOVIE_API_HOST")
if os.getenv("MOVIE_API_PORT"):
PORT = os.getenv("MOVIE_API_PORT")
app.run(host=HOST, port=PORT, threaded=True, debug=True)
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3'

services:
api:
build:
context: .
dockerfile: flask.dockerfile
ports:
- "5000:5000"
volumes:
- ./api:/movie_name/api
11 changes: 11 additions & 0 deletions flask.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.8-slim

WORKDIR /movie_name

COPY . /movie_name

RUN pip3 install flask==2.1.0 werkzeug==2.1.1 flask-cors==4.0.1 sqlalchemy==1.4.22 python-dotenv

EXPOSE 5000

CMD ["python3", "-m", "api.app"]