-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
124 lines (104 loc) · 5.23 KB
/
Copy pathDockerfile
File metadata and controls
124 lines (104 loc) · 5.23 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# =============================================================================
# TelemetryFlow PHP SDK - Dockerfile
# =============================================================================
#
# TelemetryFlow PHP SDK - AI-Powered Observability & Incident Response Management (IRM) Platform
# Copyright (c) 2024-2026 Telemetri Data Indonesia. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# =============================================================================
# Multi-stage build for minimal image size.
# Ships the `telemetryflow-gen` CLI plus a runtime copy of the SDK for example apps.
# =============================================================================
# -----------------------------------------------------------------------------
# Stage 1: Builder — install all dependencies + build the generator Phar
# -----------------------------------------------------------------------------
FROM php:8.2-alpine AS builder
# Build arguments
ARG VERSION=1.0.0
ARG GIT_COMMIT=unknown
ARG GIT_BRANCH=unknown
ARG BUILD_TIME=unknown
# Install build dependencies + PHP extensions (grpc optional, opcache for speed)
RUN apk add --no-cache git make ca-certificates tzdata \
icu-dev libzip-dev oniguruma-dev \
&& docker-php-ext-configure zip \
&& docker-php-ext-install -j$(nproc) opcache zip \
&& docker-php-ext-enable opcache
# Copy Composer from the official image
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /build
# Copy root + package manifests first for better layer caching
COPY composer.json ./
COPY packages/ ./packages/
# Install all dependencies (including dev tooling needed to build the Phar)
RUN composer install --no-interaction --prefer-dist --no-scripts
# Copy the rest of the source
COPY . .
# Dump optimized autoloader
RUN composer dump-autoload --optimize
# Build a standalone Phar for the generator CLI
RUN php -d phar.readonly=0 packages/generator/bin/build-phar.php || \
echo "Phar build skipped (build script not present); using composer binary."
# -----------------------------------------------------------------------------
# Stage 2: Runtime — minimal image with PHP + generator + SDK
# -----------------------------------------------------------------------------
FROM php:8.2-alpine
LABEL org.opencontainers.image.title="TelemetryFlow PHP SDK" \
org.opencontainers.image.description="PHP SDK and code generator for TelemetryFlow integration - AI-Powered Observability & IRM Platform" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.vendor="TelemetryFlow" \
org.opencontainers.image.authors="Telemetri Data Indonesia <support@telemetryflow.id>" \
org.opencontainers.image.url="https://telemetryflow.id" \
org.opencontainers.image.documentation="https://docs.telemetryflow.id" \
org.opencontainers.image.source="https://github.com/telemetryflow/telemetryflow-php-sdk" \
org.opencontainers.image.licenses="Apache-2.0" \
io.telemetryflow.product="TelemetryFlow PHP SDK" \
io.telemetryflow.component="telemetryflow-sdk" \
io.telemetryflow.platform="CEOP" \
io.telemetryflow.maintainer="Telemetri Data Indonesia"
# Runtime dependencies
RUN apk add --no-cache ca-certificates tzdata icu-libs libzip \
&& docker-php-ext-install opcache zip \
&& rm -rf /var/cache/apk/*
# Create non-root user and group
RUN addgroup -g 10001 -S telemetryflow && \
adduser -u 10001 -S telemetryflow -G telemetryflow -h /home/telemetryflow
# Copy the built application from the builder stage
COPY --from=builder --chown=telemetryflow:telemetryflow /build /app
# Symlink the generator binary into PATH
RUN ln -s /app/packages/generator/bin/telemetryflow-gen /usr/local/bin/telemetryflow-gen \
&& chmod +x /app/packages/generator/bin/telemetryflow-gen
USER telemetryflow
WORKDIR /workspace
# =============================================================================
# Entrypoint & Command
# =============================================================================
ENTRYPOINT ["/usr/local/bin/telemetryflow-gen"]
CMD ["--help"]
# =============================================================================
# Build Information
# =============================================================================
# Build with:
# docker build --build-arg VERSION=1.0.0 -t telemetryflow/telemetryflow-php-sdk:1.0.0 .
#
# Run with:
# # SDK Generator
# docker run --rm -v $(pwd):/workspace telemetryflow/telemetryflow-php-sdk:1.0.0 \
# init --project myapp --service my-service --output /workspace
#
# # Generate an example
# docker run --rm -v $(pwd):/workspace telemetryflow/telemetryflow-php-sdk:1.0.0 \
# example basic --output /workspace/example
# =============================================================================