-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (53 loc) · 1.9 KB
/
Dockerfile
File metadata and controls
71 lines (53 loc) · 1.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
FROM haskell:9.12.2-bookworm AS build
ENV CABAL_DIR="/root/.cabal"
RUN mkdir /opt/build
WORKDIR /opt/build
COPY ./sabela.cabal /opt/build/
RUN cabal update
RUN cabal build --only-dependencies
COPY . /opt/build
RUN mkdir -p /opt/bin \
&& cabal build exe:sabela \
&& cp "$(cabal list-bin sabela)" /opt/bin/sabela \
&& strip /opt/bin/sabela
# Pre-install dataframe package in build stage so we can copy the store
RUN cabal install dataframe
# ---------- Runtime ----------
FROM haskell:9.12.2-bookworm
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-venv \
curl \
&& rm -rf /var/lib/apt/lists/*
# ---------- Assemble final image ----------
WORKDIR /opt/sabela
# Copy compiled binary
COPY --from=build /opt/bin/sabela /opt/bin/sabela
# Copy pre-built cabal store and package index from build stage
COPY --from=build /root/.cabal/store /root/.cabal/store
COPY --from=build /root/.cabal/packages /root/.cabal/packages
# Copy static assets
COPY --from=build /opt/build/static/ /opt/sabela/static/
COPY --from=build /opt/build/display/ /opt/sabela/display/
COPY ./examples /opt/sabela/examples/
ENV CABAL_DIR="/root/.cabal"
# Entrypoint script prepends EFS tool paths to PATH at runtime
# (avoids hardcoding PATH in task definition, which broke GHC discovery)
COPY <<'SCRIPT' /opt/bin/start.sh
#!/bin/sh
# Add EFS-mounted tools to PATH if they exist
[ -d "/mnt/sabela/python/venv/bin" ] && export PATH="/mnt/sabela/python/venv/bin:$PATH"
# If a user work directory is specified (3rd arg = sabela's 2nd arg), set it up
WORKDIR="${3:-.}"
if echo "$WORKDIR" | grep -q "^/mnt/sabela/users/"; then
mkdir -p "$WORKDIR"
# Copy examples into user dir if not already there
if [ ! -d "$WORKDIR/examples" ]; then
cp -r /opt/sabela/examples "$WORKDIR/examples"
fi
fi
exec "$@"
SCRIPT
RUN chmod +x /opt/bin/start.sh
ENTRYPOINT ["/opt/bin/start.sh"]
CMD ["/opt/bin/sabela", "3000", "."]