-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (53 loc) · 1.36 KB
/
Dockerfile
File metadata and controls
72 lines (53 loc) · 1.36 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
# Hornbeam Docker Image
# Erlang/OTP + Python runtime for WSGI/ASGI applications
FROM erlang:26 AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
git \
python3 \
python3-dev \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# Install rebar3
RUN wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3 && mv rebar3 /usr/local/bin/
WORKDIR /app
# Copy source
COPY rebar.config rebar.lock ./
COPY src ./src
COPY priv ./priv
COPY config ./config
# Build release
RUN rebar3 release
# Runtime image
FROM erlang:26-slim
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
python3-venv \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy release from builder
COPY --from=builder /app/_build/default/rel/hornbeam /app/hornbeam
# Copy examples
COPY examples /app/examples
# Create Python virtual environment
RUN python3 -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
# Default port
EXPOSE 8000
# Environment variables
ENV HORNBEAM_PORT=8000
ENV PYTHONPATH=/app/examples
# Start script
COPY <<'EOF' /app/start.sh
#!/bin/bash
set -e
# Install Python dependencies if requirements.txt exists
if [ -f "$APP_DIR/requirements.txt" ]; then
pip install -r "$APP_DIR/requirements.txt"
fi
# Start Hornbeam
exec /app/hornbeam/bin/hornbeam foreground
EOF
RUN chmod +x /app/start.sh
CMD ["/app/start.sh"]