Skip to content

Commit f58ee56

Browse files
author
niukang
committedApr 7, 2023
modify for deploying in flyio
1 parent 6634177 commit f58ee56

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed
 

‎.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
venv
2-
fly.toml
32
.vscode
43
__pycache__

‎Dockerfile

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Use an official Python runtime as a parent image
2+
3+
FROM python:3.8-slim-buster
4+
5+
6+
7+
# Set the working directory to /app
8+
WORKDIR /app
9+
10+
11+
12+
# Copy the current directory contents into the container at /app
13+
COPY . /app
14+
15+
16+
17+
# Install any needed packages specified in requirements.txt
18+
RUN pip install --trusted-host pypi.python.org -r requirements.txt
19+
20+
21+
22+
RUN apt-get update && \
23+
apt-get install -y procps
24+
25+
26+
27+
# Make port 80 available to the world outside this container
28+
EXPOSE 80
29+
30+
31+
32+
# Define environment variable
33+
ENV NAME World
34+
35+
36+
37+
# Run app.py when the container launches
38+
CMD ["python", "hellofly.py"]

‎fly.toml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# fly.toml file generated for helloabc on 2023-04-07T10:40:34+08:00
2+
3+
app = "helloabc"
4+
kill_signal = "SIGINT"
5+
kill_timeout = 5
6+
primary_region = "nrt"
7+
8+
[[services]]
9+
protocol = "tcp"
10+
internal_port = 5000
11+
processes = ["app"]
12+
13+
[[services.ports]]
14+
port = 80
15+
handlers = ["http"]
16+
force_https = true
17+
18+
[[services.ports]]
19+
port = 443
20+
handlers = ["tls", "http"]
21+
[services.concurrency]
22+
type = "connections"
23+
hard_limit = 25
24+
soft_limit = 20

‎hellofly.py

+2
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
def hello(name=None):
88
return render_template('hello.html', name=name)
99

10+
if __name__ == '__main__':
11+
app.run(host='0.0.0.0', port=5000)

0 commit comments

Comments
 (0)
Please sign in to comment.