-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
194 lines (164 loc) · 5.9 KB
/
Dockerfile
File metadata and controls
194 lines (164 loc) · 5.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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# =============================================================================
# ARO Programming Language - Dockerfile
# =============================================================================
# Multi-stage build for the ARO compiler and runtime
#
# Build: docker build -t aro .
# Run: docker run -v $(pwd)/myapp:/app aro run /app
# =============================================================================
# -----------------------------------------------------------------------------
# Stage 1: Build Environment
# -----------------------------------------------------------------------------
FROM swift:6.2-jammy AS builder
# Build arguments for version info
ARG VERSION=dev
ARG COMMIT_SHA=unknown
# Install build dependencies including LLVM 20 (required for Swifty-LLVM) and Rust (for plugins)
RUN apt-get update && apt-get install -y --no-install-recommends \
libcurl4-openssl-dev \
libssl-dev \
wget \
gnupg \
lsb-release \
software-properties-common \
pkg-config \
curl \
libgit2-dev \
&& wget https://apt.llvm.org/llvm.sh \
&& chmod +x llvm.sh \
&& ./llvm.sh 20 \
&& apt-get install -y --no-install-recommends llvm-20-dev \
&& ln -sf /usr/bin/llc-20 /usr/bin/llc \
&& rm -rf /var/lib/apt/lists/* \
&& rm llvm.sh
# Install Rust for plugin compilation
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& . $HOME/.cargo/env \
&& rustup default stable
ENV PATH="/root/.cargo/bin:${PATH}"
# Create pkg-config file for LLVM 20
RUN mkdir -p /usr/lib/pkgconfig && \
printf '%s\n' \
'prefix=/usr/lib/llvm-20' \
'exec_prefix=${prefix}' \
'libdir=${prefix}/lib' \
'includedir=${prefix}/include' \
'' \
'Name: LLVM' \
'Description: Low-level Virtual Machine compiler framework' \
'Version: 20.0.0' \
'Libs: -L${libdir} -lLLVM-20' \
'Cflags: -I${includedir}' \
> /usr/lib/pkgconfig/llvm.pc
WORKDIR /build
# Copy package manifest first for better caching
COPY Package.swift Package.resolved ./
# Fetch dependencies (cached layer)
RUN swift package resolve
# Copy source files
COPY Sources/ Sources/
COPY Tests/ Tests/
# Build release binary
RUN swift build -c release \
-Xswiftc -DVERSION=\"${VERSION}\" \
-Xswiftc -DCOMMIT_SHA=\"${COMMIT_SHA}\" \
--static-swift-stdlib
# Run tests to verify build
RUN swift test --parallel
# -----------------------------------------------------------------------------
# Stage 2: Runtime Environment
# -----------------------------------------------------------------------------
FROM swift:6.2-jammy AS runtime
# Labels for container metadata
LABEL org.opencontainers.image.title="ARO Programming Language"
LABEL org.opencontainers.image.description="The ARO Programming Language - Speak Business. Write Code."
LABEL org.opencontainers.image.vendor="Anthropic"
LABEL org.opencontainers.image.source="https://github.com/arolang/aro"
LABEL org.opencontainers.image.documentation="https://github.com/arolang/aro/blob/main/Documentation"
ARG VERSION=dev
ARG COMMIT_SHA=unknown
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.revision="${COMMIT_SHA}"
# Install runtime dependencies including LLVM 20 and Rust (for plugins)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libcurl4 \
libssl3 \
wget \
gnupg \
lsb-release \
software-properties-common \
curl \
python3 \
build-essential \
&& wget -qO- https://apt.llvm.org/llvm.sh | bash -s -- 20 \
&& apt-get install -y --no-install-recommends llvm-20 clang-20 \
&& ln -sf /usr/bin/llc-20 /usr/bin/llc \
&& ln -sf /usr/bin/clang-20 /usr/bin/clang \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -m -s /bin/bash aro
# Install Rust for plugin compilation
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& . $HOME/.cargo/env \
&& rustup default stable
ENV PATH="/root/.cargo/bin:${PATH}"
# Copy the built binary and runtime library
COPY --from=builder /build/.build/release/aro /usr/local/bin/aro
COPY --from=builder /build/.build/release/libARORuntime.a /usr/local/lib/libARORuntime.a
# Copy examples for reference
COPY Examples/ /opt/aro/examples/
# Set up working directory
WORKDIR /app
# Switch to non-root user
USER aro
# Default command shows help
ENTRYPOINT ["aro"]
CMD ["--help"]
# -----------------------------------------------------------------------------
# Stage 3: Development Environment (optional)
# -----------------------------------------------------------------------------
FROM swift:6.2-jammy AS dev
# Install development tools including LLVM 20 and Rust (for plugins)
RUN apt-get update && apt-get install -y --no-install-recommends \
vim \
git \
curl \
jq \
wget \
gnupg \
lsb-release \
software-properties-common \
pkg-config \
python3 \
build-essential \
&& wget -qO- https://apt.llvm.org/llvm.sh | bash -s -- 20 \
&& apt-get install -y --no-install-recommends llvm-20-dev clang-20 \
&& ln -sf /usr/bin/llc-20 /usr/bin/llc \
&& ln -sf /usr/bin/clang-20 /usr/bin/clang \
&& rm -rf /var/lib/apt/lists/*
# Install Rust for plugin compilation
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& . $HOME/.cargo/env \
&& rustup default stable
ENV PATH="/root/.cargo/bin:${PATH}"
# Create pkg-config file for LLVM 20
RUN mkdir -p /usr/lib/pkgconfig && \
printf '%s\n' \
'prefix=/usr/lib/llvm-20' \
'exec_prefix=${prefix}' \
'libdir=${prefix}/lib' \
'includedir=${prefix}/include' \
'' \
'Name: LLVM' \
'Description: Low-level Virtual Machine compiler framework' \
'Version: 20.0.0' \
'Libs: -L${libdir} -lLLVM-20' \
'Cflags: -I${includedir}' \
> /usr/lib/pkgconfig/llvm.pc
WORKDIR /workspace
# Copy source for development
COPY . .
# Build in debug mode for faster iteration
RUN swift build
# Development shell
CMD ["/bin/bash"]