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
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10.13
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ubuntu:22.04
RUN useradd -u 1001 testuser
RUN apt-get update \
&& apt-get install python3 python3-pip -y \
&& mkdir /app/ \
&& mkdir /req/
ADD requirements.txt /req/
RUN pip install -r /req/requirements.txt
ADD app /app
EXPOSE 5000
# Use this user here, because of permissions
USER testuser
ENTRYPOINT ["python3"]
CMD ["/app/app.py"]
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
# devops-programme
# devops-programme

## How to build it on Ubuntu 22.04 LTS
```bash
$ sudo docker build -t test:v0.1 .

...
Successfully built 14fd734fcfc3
Successfully tagged test:v0.1

$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test v0.1 14fd734fcfc3 5 minutes ago 476MB
```

## How to run it on Ubuntu 22.04 LTS
```bash
$ sudo docker build -t test:v0.1 .
2ff974622935c628227b58162eba6445d22cbba9272bd35a4f2dbe4992dd7a6e

$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2ff974622935 test:v0.1 "python3 /app/app.py" 4 minutes ago Up 4 minutes 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp nifty_bose

$ netstat -nltp | grep 5000
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN -

$ curl http://127.0.0.1:5000/
Hello, World!
```
15 changes: 15 additions & 0 deletions app/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os

from flask import Flask

app = Flask(__name__)


@app.route("/")
def hello_world():
return "Hello, World!"


if __name__ == "__main__":
# Allow running on localhost
app.run(debug=True, host='0.0.0.0', port=os.environ.get("PORT", 5000))
17 changes: 17 additions & 0 deletions app/app_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import unittest

from app import app


class TestApp(unittest.TestCase):
def setUp(self):
self.client = app.test_client()

def test_hello_world(self):
response = self.client.get("/")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data, b"Hello, World!")


if __name__ == "__main__":
unittest.main()
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blinker==1.6.3 ; python_version >= "3.10" and python_version < "4.0"
click==8.1.7 ; python_version >= "3.10" and python_version < "4.0"
colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows"
flask==3.0.0 ; python_version >= "3.10" and python_version < "4.0"
itsdangerous==2.1.2 ; python_version >= "3.10" and python_version < "4.0"
jinja2==3.1.2 ; python_version >= "3.10" and python_version < "4.0"
markupsafe==2.1.3 ; python_version >= "3.10" and python_version < "4.0"
werkzeug==3.0.0 ; python_version >= "3.10" and python_version < "4.0"