https://github.com/ocdbytes/webapp_backend_dockerised
Backend API dockerised. Made with python fast api library and then image is built out of it.
https://github.com/ocdbytes/webapp_backend_dockerised
docker dockerfile fastapi python
Last synced: 11 months ago
JSON representation
Backend API dockerised. Made with python fast api library and then image is built out of it.
- Host: GitHub
- URL: https://github.com/ocdbytes/webapp_backend_dockerised
- Owner: ocdbytes
- Created: 2022-06-12T17:30:57.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-09T14:42:36.000Z (almost 3 years ago)
- Last Synced: 2024-04-14T10:46:09.914Z (almost 2 years ago)
- Topics: docker, dockerfile, fastapi, python
- Language: Python
- Homepage:
- Size: 6.05 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# WebApp Dockerised
We need to first make a virtual environment for our application in our system
```bash
python3 -m venv venv
. venv/bin/activate
```
This project
```bash
docker pull w3ts0ck3t/devops_project
```
Now we will create our requirements file in project root using
```bash
pip freeze > requirements.txt
```
Let's create our Dockerfile
```Dockerfile
FROM python:3.8
WORKDIR /fastapi-app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY ./app ./app
CMD ["python", "./app/main.py"]
```
Build our image on docker
```bash
docker build -t python-fastapi-app .
```
If we want to forward our port
```bash
docker run -p 8000:8000 python-fastapi-app
```
If we want to get the shell inside the container we can get it using
```bash
docker exec -it /bin/sh
```
If we want to push our image to docker hub
```bash
docker tag python-fastapi-app:latest /:latest
docker push /:latest
```
After pushing pull the project
```bash
docker pull /:
```