Skip to content

myself-sukant/docker-fastapi-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 


FastAPI Docker User API

This project is a simple FastAPI application that handles user data using a JSON file instead of a database. The entire application is containerized using Docker and can be run using Docker Compose.


Project Features

  • Built using FastAPI
  • Stores user data in a users.json file (no database used)
  • Containerized using Docker
  • Easy to run with docker-compose
  • API documentation available at /docs

Project Structure

docker-fastapi-userapi/
├── app/
│   ├── main.py            # FastAPI app entry point
│   ├── services.py        # Logic to handle file operations
│   └── data/              # Contains users.json
│       └── users.json     # Auto-created when user data is posted
├── Dockerfile             # Docker image instructions
├── docker-compose.yml     # Docker Compose file
├── requirements.txt       # Python dependencies
└── README.md              # Project documentation

User Payload

{
  "data": [
     {
        "first_name": "Sukant"
        "last_name": "Tekade"
        "age": 23
     }
  ] 
}

Dockerfile

FROM python:3.12-slim

WORKDIR /app

COPY . /app

RUN pip install --no-cache-dir -r /app/requirements.txt

USER root

EXPOSE 8000

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

Docker Compose File

version: '3.8'

services:
  fastapi-app:
    build: .
    container_name: fastapi-app
    ports:
      - "8000:8000"
    volumes:
      - .:/app
      - ./app/data:/app/app/data
    restart: always

Author


About

Devops Machine test- Nimap Task

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors