-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (53 loc) · 1.9 KB
/
Dockerfile
File metadata and controls
71 lines (53 loc) · 1.9 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Multi-stage build for smaller final image
FROM python:3.11-alpine AS builder
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install build dependencies
RUN apk add --no-cache gcc musl-dev libffi-dev
# Set working directory
WORKDIR /app
# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --target=/install -r requirements.txt
# Copy application code
COPY terratunnel/ terratunnel/
# Production stage
FROM python:3.11-alpine
# Set metadata
LABEL maintainer="Terratunnel Team <hello@terrateam.io>" \
description="A secure HTTP tunnel server and client for forwarding webhooks to local development environments" \
version="1.0.0"
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Create non-root user for security
RUN addgroup -S terratunnel && adduser -S terratunnel -G terratunnel
# Create data directory for persistent storage
RUN mkdir -p /data && chown terratunnel:terratunnel /data
# Install runtime dependencies only
RUN apk add --no-cache libffi libmagic
# Copy installed packages and application code from builder
COPY --from=builder /install /usr/local/lib/python3.11/site-packages
COPY --from=builder /app/terratunnel /app/terratunnel
# Copy static assets
COPY logo-wordmark.svg /app/logo-wordmark.svg
COPY logo-symbol.svg /app/logo-symbol.svg
COPY fonts/ /app/fonts/
# Set Python path to include the app directory
ENV PYTHONPATH=/app
WORKDIR /app
# Switch to non-root user
USER terratunnel
# Expose common ports
EXPOSE 8000 8080 8081
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -m terratunnel --help > /dev/null || exit 1
# Default command (can be overridden)
ENTRYPOINT ["python", "-m", "terratunnel"]
CMD ["--help"]