dockerfiles added
This commit is contained in:
49
apps/simulator/Dockerfile
Normal file
49
apps/simulator/Dockerfile
Normal file
@@ -0,0 +1,49 @@
|
||||
# Simulator Service Dockerfile
|
||||
# FastAPI Web UI + MQTT Device Simulator
|
||||
|
||||
FROM python:3.14-alpine
|
||||
|
||||
# Prevent Python from writing .pyc files and enable unbuffered output
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
MQTT_BROKER=172.16.2.16 \
|
||||
MQTT_PORT=1883 \
|
||||
SIM_PORT=8010
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -g 10001 -S app && \
|
||||
adduser -u 10001 -S app -G app
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apk add --no-cache \
|
||||
curl \
|
||||
gcc \
|
||||
musl-dev \
|
||||
linux-headers
|
||||
|
||||
# Install Python dependencies
|
||||
COPY apps/simulator/requirements.txt /app/requirements.txt
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy application code
|
||||
COPY apps/__init__.py /app/apps/__init__.py
|
||||
COPY apps/simulator/ /app/apps/simulator/
|
||||
|
||||
# Change ownership to app user
|
||||
RUN chown -R app:app /app
|
||||
|
||||
# Switch to non-root user
|
||||
USER app
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8010/health || exit 1
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8010
|
||||
|
||||
# Run the simulator
|
||||
CMD ["python", "-m", "uvicorn", "apps.simulator.main:app", "--host", "0.0.0.0", "--port", "8010"]
|
||||
4
apps/simulator/requirements.txt
Normal file
4
apps/simulator/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
fastapi==0.104.1
|
||||
uvicorn[standard]==0.24.0
|
||||
aiomqtt==2.0.1
|
||||
jinja2==3.1.2
|
||||
Reference in New Issue
Block a user