-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
80 lines (65 loc) · 2.78 KB
/
Copy pathDockerfile
File metadata and controls
80 lines (65 loc) · 2.78 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
72
73
74
75
76
77
78
79
80
FROM alpine:3.21 AS builder
# Version as build argument for easier updates
ARG DATAPLANEAPI_VERSION=v3.1.4
# Download DataPlane API
RUN apk add --no-cache wget && \
wget "https://github.com/haproxytech/dataplaneapi/releases/download/${DATAPLANEAPI_VERSION}/dataplaneapi_${DATAPLANEAPI_VERSION#v}_linux_amd64.apk" -O /tmp/dataplaneapi.apk
FROM alpine:3.21
# Version info for labels
ARG DATAPLANEAPI_VERSION=v3.1.4
ARG BUILD_DATE
ARG VCS_REF
# Metadata labels
LABEL maintainer="Telxey <info@telxey.com>" \
description="Standalone HAProxy DataPlane API for managing HAProxy configurations" \
version="${DATAPLANEAPI_VERSION}" \
org.opencontainers.image.title="Standalone HAProxy DataPlane API" \
org.opencontainers.image.description="Enterprise-ready standalone HAProxy DataPlane API container" \
org.opencontainers.image.version="${DATAPLANEAPI_VERSION}" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.source="https://github.com/haproxytech/dataplaneapi" \
org.opencontainers.image.url="https://github.com/telxey/haproxy-dataplaneapi" \
org.opencontainers.image.documentation="https://www.haproxy.com/documentation/dataplaneapi/" \
org.opencontainers.image.licenses="MIT"
# Install dependencies and set up user (without haproxy)
RUN apk add --no-cache \
ca-certificates \
curl \
jq \
socat \
tzdata && \
addgroup -S haproxy && \
adduser -S -G haproxy haproxy
# Copy and install DataPlane API from builder stage
COPY --from=builder /tmp/dataplaneapi.apk /tmp/
RUN apk add --allow-untrusted /tmp/dataplaneapi.apk && \
rm /tmp/dataplaneapi.apk
# Create necessary directories with consistent paths
RUN mkdir -p /etc/haproxy/maps \
/etc/haproxy/certs \
/etc/haproxy/ssl \
/etc/haproxy/lua \
/etc/haproxy/spoe \
/var/run/haproxy \
/var/log/dataplaneapi && \
chown -R haproxy:haproxy /etc/haproxy \
/var/run/haproxy \
/var/log/dataplaneapi
# Copy entrypoint script
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Define volumes for persistent data
VOLUME ["/etc/haproxy", "/var/log/dataplaneapi"]
# Set working directory
WORKDIR /etc/haproxy
# Add health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD curl -s -f -u "${API_USER:-admin}:${API_PASSWORD:-mypassword}" "http://localhost:${API_PORT:-5555}/v2/health" || exit 1
# Expose API port
EXPOSE 5555
# Switch to non-root user for better security
USER haproxy
# Set entrypoint and default command
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["--config-file", "/etc/haproxy/dataplaneapi.yml"]