Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (36 loc) · 1.4 KB
/
Copy pathDockerfile
File metadata and controls
48 lines (36 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Lisboa Environmental Sensor Collector - Docker Image
# Runs on TrueNAS Scale (Debian-based) and any Docker-compatible platform
FROM python:3.13-slim
# Metadata
LABEL maintainer="Paulo"
LABEL description="Collects hourly environmental sensor data from Lisboa Aberta API"
LABEL version="1.0"
# Set working directory
WORKDIR /app
# Install system dependencies (certificates for SSL, tzdata for timezone, cron for scheduling)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
tzdata \
cron \
&& rm -rf /var/lib/apt/lists/*
# Set timezone to UTC (API returns UTC timestamps)
ENV TZ=UTC
# Copy requirements first (for better layer caching)
COPY requirements-dev.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements-dev.txt
# Copy application code
COPY src/ ./src/
COPY sensors.json .
# Copy entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Create data directory for CSV output
RUN mkdir -p /app/data
# Create non-root user for security
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
# Default command - runs once and exits (intended for cron/ScheduledTask)
# For hourly runs, set CRON_SCHEDULE="0 * * * *" environment variable
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["--config", "sensors.json", "--out-dir", "data"]