-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (44 loc) · 1.81 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (44 loc) · 1.81 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
49
50
51
52
53
54
55
56
FROM python:3.13-slim
# Metadata labels for Docker Hub and OCI compliance
LABEL maintainer="aaronzi"
LABEL description="OPC UA Time Series Server"
LABEL version="1.0.0"
LABEL org.opencontainers.image.source="https://github.com/aaronzi/opcua-timeseries"
LABEL org.opencontainers.image.description="A containerized OPC UA server for time series data"
LABEL org.opencontainers.image.licenses="LGPL-3.0+"
LABEL org.opencontainers.image.title="OPC UA Time Series Server"
LABEL org.opencontainers.image.authors="aaronzi"
LABEL org.opencontainers.image.vendor="aaronzi"
LABEL org.opencontainers.image.documentation="https://github.com/aaronzi/opcua-timeseries"
LABEL org.opencontainers.image.url="https://github.com/aaronzi/opcua-timeseries"
# Set working directory
WORKDIR /app
# Install system dependencies with specific versions for reproducibility
RUN apt-get update && apt-get install -y \
gcc=4:12.2.0-3 \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Copy requirements first for better Docker layer caching
COPY requirements.txt .
# Install Python dependencies with hash verification for security
RUN pip install --no-cache-dir --require-hashes -r requirements.txt || \
pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY server/ ./server/
COPY config/ ./config/
# Create logs directory
RUN mkdir -p logs
# Expose OPC UA port
EXPOSE 4840
# Set environment variables
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# Create non-root user
RUN groupadd -r opcua && useradd -r -g opcua opcua
RUN chown -R opcua:opcua /app
USER opcua
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD python -c "import asyncio; from server.client_test import test_connection; asyncio.run(test_connection())" || exit 1
# Run the server
CMD ["python", "-m", "server.main"]