-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile
More file actions
159 lines (129 loc) · 4.84 KB
/
Copy pathContainerfile
File metadata and controls
159 lines (129 loc) · 4.84 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Trigger Containerfile
#
# Multi-stage build for Trigger application
# Author: hyperpolymath
#
# Usage:
# podman build -t hyperpolymath/trigger:latest .
# podman run -it hyperpolymath/trigger:latest
#
# or with Docker (alias):
# docker build -t hyperpolymath/trigger:latest .
# docker run -it hyperpolymath/trigger:latest
# =============================================================================
# Stage 1: Build Ada/SPARK application
# =============================================================================
FROM ghcr.io/alire-project/gnat-native:latest AS builder
# Set environment
ENV APP_NAME=trigger \
APP_VERSION=1.0.0 \
BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
BUILD_COMMIT="$(git rev-parse HEAD 2>/dev/null || echo 'unknown')" \
BUILD_BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'unknown')" \
DEBIAN_FRONTEND=noninteractive
WORKDIR /app
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
wget \
curl \
ca-certificates \
pkg-config \
libsodium-dev \
libssl-dev \
zlib1g-dev \
make \
cmake \
&& rm -rf /var/lib/apt/lists/*
# Copy source files
COPY . .
# Build with GNAT
RUN mkdir -p obj bin && \
gprbuild -P trigger.gpr -XLIBRARY_TYPE=static && \
cp obj/trigger bin/trigger
# =============================================================================
# Stage 2: Install Zig for FFI
# =============================================================================
FROM ghcr.io/alire-project/gnat-native:latest AS zig-builder
WORKDIR /app
# Install Zig
RUN wget -O /tmp/zig.tar.xz https://ziglang.org/builds/zig-linux-x86_64-0.11.0.tar.xz && \
tar -xf /tmp/zig.tar.xz -C /usr/local && \
ln -s /usr/local/zig-linux-x86_64-0.11.0/zig /usr/local/bin/zig && \
rm /tmp/zig.tar.xz
# Copy files from previous stage
COPY --from=builder /app /app
# Build Zig FFI
RUN cd ffi/zig && \
zig build-lib -dynamic telegram.zig && \
zig build-lib -dynamic discord.zig && \
zig build-lib -dynamic twitter.zig && \
zig build-lib -dynamic crypto/crypto.zig && \
cd ../..
# =============================================================================
# Stage 3: Runtime image
# =============================================================================
FROM debian:stable-slim AS runtime
# Set environment
ENV APP_NAME=trigger \
APP_VERSION=1.0.0 \
PATH="/app/bin:${PATH}"
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgcc-s1 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create directory structure
RUN mkdir -p bin config sessions logs tmp
# Copy built binaries from builder
COPY --from=builder /app/bin/trigger bin/trigger
COPY --from=builder /app/ffi/zig/libtelegram.so lib/
COPY --from=builder /app/ffi/zig/libdiscord.so lib/
COPY --from=builder /app/ffi/zig/libtwitter.so lib/
COPY --from=builder /app/ffi/zig/libcrypto.so lib/
# Set permissions
RUN chmod +x bin/trigger && \
chmod 750 sessions logs tmp
# =============================================================================
# Stage 4: Final image with all components
# =============================================================================
FROM runtime AS final
# Copy documentation and configuration
COPY LICENSE LICENSES/ README.adoc CONTRIBUTING.adoc GOVERNANCE.adoc .
COPY docs/ /app/docs/
COPY .editorconfig .gitignore .gitattributes .
# Copy www files
COPY www/ /app/www/
# Copy scripts
COPY scripts/ /app/scripts/
# Copy machine-readable metadata
COPY .machine_readable/ /app/.machine_readable/
# Set default configuration
RUN mkdir -p .machine_readable/metadata && \
echo '{"name":"trigger","version":"1.0.0","description":"Telegram reporting utility","author":"hyperpolymath"}' > .machine_readable/metadata/trigger.json
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD ["/app/bin/trigger", "--health"] || exit 1
# Entrypoint
ENTRYPOINT ["/app/bin/trigger"]
CMD ["--help"]
# Expose ports (if needed for future web interface)
EXPOSE 8080
# Volume for persistent data
VOLUME ["/app/sessions", "/app/logs", "/app/config"]
# Labels
LABEL org.opencontainers.image.title="Trigger" \
org.opencontainers.image.description="Telegram channel reporting utility" \
org.opencontainers.image.version="1.0.0" \
org.opencontainers.image.author="hyperpolymath" \
org.opencontainers.image.url="https://github.com/hyperpolymath/trigger" \
org.opencontainers.image.licenses="MPL-2.0,CC-BY-SA-4.0" \
org.opencontainers.image.source="https://github.com/hyperpolymath/trigger" \
maintainer="hyperpolymath <hyperpolymath@users.noreply.github.com>"
# User to run as (non-root)
RUN adduser --disabled-password --gecos '' appuser && \
chown -R appuser:appuser /app
USER appuser