Skip to content
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
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use an official Python runtime as the base image
FROM python:3.9-slim

# Set the working directory in the container
WORKDIR /app

# Copy the requirements file into the container
COPY requirements.txt .

# Install the required packages
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code into the container
COPY . .

# Set environment variables
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0

# Expose the port on which the app will run
EXPOSE 5000

# Run the Flask application
CMD ["flask", "run", "--host=0.0.0.0"]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ flask run

Go to http://127.0.0.1:5000/

or you can use `docker` to run this project:
```
docker-compose up
```

## More details
关于这个项目的详细介绍:[Flask实践:计算器](https://zhuanlan.zhihu.com/p/24120882)
更多关于Flask的原创优质内容,欢迎关注[Hello, Flask!——知乎专栏](https://zhuanlan.zhihu.com/flask)
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
calculator:
build: .
container_name: calculator
ports:
- "5000:5000"
networks:
- calculator-network

networks:
calculator-network:
driver: bridge
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ Werkzeug==0.13
# deploy
gunicorn==19.5.0
gevent
markupsafe==2.0.1
itsdangerous==2.0.1