-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (58 loc) · 2.27 KB
/
Dockerfile
File metadata and controls
73 lines (58 loc) · 2.27 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
# Perry TypeScript Compiler - Multi-stage Docker Build
#
# This Dockerfile builds Perry and can be used to:
# 1. Build Perry from source on Linux
# 2. Compile TypeScript files to native Linux executables
# 3. Create minimal runtime images with compiled binaries
#
# Usage:
# docker build -t perry .
# docker run -v $(pwd):/app perry /app/myfile.ts -o /app/myfile
# =============================================================================
# Stage 1: Build Perry compiler
# =============================================================================
FROM rust:1.75-bookworm AS builder
WORKDIR /perry
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy Cargo files first for dependency caching
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
# Build release binaries
RUN cargo build --release
RUN cargo build --release -p perry-runtime
# =============================================================================
# Stage 2: Runtime image for compiling TypeScript
# =============================================================================
FROM debian:bookworm-slim AS compiler
# Install minimal runtime dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libssl3 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /perry
# Copy Perry compiler and runtime library
COPY --from=builder /perry/target/release/perry /usr/local/bin/perry
COPY --from=builder /perry/target/release/libperry_runtime.a /usr/local/lib/libperry_runtime.a
# Set library path for linking
ENV PERRY_RUNTIME_LIB=/usr/local/lib/libperry_runtime.a
ENTRYPOINT ["perry"]
# =============================================================================
# Stage 3: Minimal image for running compiled binaries only
# =============================================================================
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y \
libssl3 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# This stage is meant to be used with COPY --from to add your compiled binary
# Example in your Dockerfile:
# FROM perry:runtime
# COPY --from=builder /app/myprogram /app/myprogram
# CMD ["/app/myprogram"]