-
Notifications
You must be signed in to change notification settings - Fork 8
Commit v0.1
kwmccabe edited this page Apr 17, 2018
·
17 revisions
v0.1 - Hello FlaskApp: docker-compose.yml, web/Dockerfile, web/requirements.txt, web/flaskapp.py
- +7 -0 [A] docker-compose.yml
- +14 -0 [A] web/Dockerfile
- +6 -0 [A] web/flaskapp.py
- +2 -0 [A] web/requirements.txt
- This is a minimal Docker Compose file with the default name, just to get running.
-
version
: Be careful when researching Compose issues to note the version. Many version 2 solutions will not work under version 3. -
services
: Each service is a different Docker container -
web
: We'll start with a single service called web -
build
: The location of this service's Dockerfile - in this case, inside the project's web directory. -
ports
: Opens a public port 5000 and connects it to the container port 8000 -
command
: Launch the application flaskapp:app and tell gunicorn to make it available on port 8000
+version: "3"
+services:
+ web:
+ build: ./web
+ ports:
+ - "5000:8000"
+ command: /usr/local/bin/gunicorn -b :8000 flaskapp:app
- A minimal Docker file.
+# base container image
+FROM python:3.6.1-alpine
+
+# setup working directory within container
+RUN mkdir -p /web
+WORKDIR /web
+
+# copy code from current directory into working directory
+COPY . /web
+
+# setup python environment, import required modules
+RUN pip install --upgrade pip
+RUN pip install --no-cache-dir -r requirements.txt
- A minimal Flask application.
- Create the application
app
- referenced by thegunicorn
command indocker-compose.yml
- Define the default route
/
- returns the stringHello FlaskApp
+from flask import Flask
+app = Flask(__name__)
+
+@app.route('/')
+def hello_flaskapp():
+ return 'Hello FlaskApp'
- Only two packages are required at this stage. During the install,
pip
will fetch the latest versions.
+Flask
+gunicorn
About | Commit-v0.1 | Commit-v0.2
- FlaskApp Tutorial
- Table of Contents
- About
- Application Setup
- Modules, Templates, and Layouts
- Database Items, Forms, and CRUD
- List Filter, Sort, and Paginate
- Users and Login
- Database Relationships
- API Module, HTTPAuth and JSON
- Refactoring User Roles and Item Status
- AJAX and Public Pages