Add Docker support and update README with deployment options
- Add Dockerfile with multi-stage build for production deployment - Add docker-compose.yml for easy local development - Add .dockerignore to optimize Docker build context - Update README with Docker and local setup instructions
This commit is contained in:
50
.dockerignore
Normal file
50
.dockerignore
Normal file
@@ -0,0 +1,50 @@
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
*.so
|
||||
.Python
|
||||
venv/
|
||||
env/
|
||||
ENV/
|
||||
*.egg-info/
|
||||
dist/
|
||||
build/
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# Git
|
||||
.git/
|
||||
.gitignore
|
||||
|
||||
# Environment files (will be mounted separately)
|
||||
.env
|
||||
|
||||
# Documentation
|
||||
README.md
|
||||
|
||||
# CI/CD
|
||||
.github/
|
||||
|
||||
# Claude
|
||||
.claude/
|
||||
|
||||
# Instance data (will be mounted as volume)
|
||||
src/app/instance/
|
||||
src/app/static/images/
|
||||
src/app/static/barcodes/
|
||||
|
||||
# Test files
|
||||
*.pyc
|
||||
.pytest_cache/
|
||||
.coverage
|
||||
htmlcov/
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
33
Dockerfile
Normal file
33
Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
||||
# Use Python 3.11 slim image as base
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
FLASK_APP=src/run.py
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gcc \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy requirements first for better layer caching
|
||||
COPY requirements.txt .
|
||||
|
||||
# Install Python dependencies
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Create necessary directories for runtime
|
||||
RUN mkdir -p src/app/static/images src/app/static/barcodes src/app/instance
|
||||
|
||||
# Expose port 5555
|
||||
EXPOSE 5555
|
||||
|
||||
# Run the application
|
||||
CMD ["python", "src/run.py"]
|
||||
58
README.md
58
README.md
@@ -36,6 +36,47 @@ This project is a simple Flask API for demonstrating AR content retrieval for ba
|
||||
|
||||
## Setup
|
||||
|
||||
### Option 1: Docker (Recommended)
|
||||
|
||||
1. **Clone the Repository:**
|
||||
|
||||
```bash
|
||||
git clone <repository_url>
|
||||
cd <repository_folder>
|
||||
```
|
||||
|
||||
2. **Configure Environment:**
|
||||
|
||||
Copy `.env.example` to `.env` and update with your Azure AD credentials:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
Edit `.env` and set your Azure AD configuration values.
|
||||
|
||||
3. **Run with Docker Compose:**
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
The application will be available at `http://localhost:5555`
|
||||
|
||||
4. **View Logs:**
|
||||
|
||||
```bash
|
||||
docker-compose logs -f
|
||||
```
|
||||
|
||||
5. **Stop the Application:**
|
||||
|
||||
```bash
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
### Option 2: Local Python Setup
|
||||
|
||||
1. **Clone the Repository:**
|
||||
|
||||
```bash
|
||||
@@ -49,23 +90,26 @@ cd <repository_folder>
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
3. **Run the Server:**
|
||||
3. **Configure Environment:**
|
||||
|
||||
Copy `.env.example` to `.env` and update with your configuration.
|
||||
|
||||
4. **Run the Server:**
|
||||
|
||||
```bash
|
||||
python app.py
|
||||
python src/run.py
|
||||
```
|
||||
|
||||
The application will automatically create the necessary directories and initialize the products.json file if it doesn't exist.
|
||||
The application will automatically create the necessary directories and initialize the database if it doesn't exist.
|
||||
|
||||
4. **Access the Admin Interface:**
|
||||
### Accessing the Application
|
||||
|
||||
Open your browser and navigate to:
|
||||
**Admin Interface:**
|
||||
```
|
||||
http://localhost:5555/admin
|
||||
```
|
||||
|
||||
5. **Test the Endpoints:**
|
||||
|
||||
**API Endpoints:**
|
||||
* Login: `GET http://localhost:5555/login`
|
||||
* Content Fields: `GET http://localhost:5555/arcontentfields`
|
||||
* AR Info (Example): `GET http://localhost:5555/arinfo?barcode=123456`
|
||||
|
||||
19
docker-compose.yml
Normal file
19
docker-compose.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
container_name: kcap-demo-server
|
||||
ports:
|
||||
- "5555:5555"
|
||||
environment:
|
||||
- FLASK_DEBUG=1
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
# Mount static directories for persistent storage
|
||||
- ./src/app/static/images:/app/src/app/static/images
|
||||
- ./src/app/static/barcodes:/app/src/app/static/barcodes
|
||||
# Mount instance directory for database persistence
|
||||
- ./src/app/instance:/app/src/app/instance
|
||||
restart: unless-stopped
|
||||
Reference in New Issue
Block a user