-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathDockerfile
72 lines (55 loc) · 1.99 KB
/
Dockerfile
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
##
# Dev stage: outputs an alpine image with everything needed for development.
# (this image is used by the `make ready` command to create a dev environment)
FROM alpine:3.15 as dev
# Install build tools, Pony dependencies, LLVM libraries, and Crystal.
RUN apk add --no-cache --update \
sudo \
alpine-sdk coreutils linux-headers clang-dev lld \
valgrind perl lldb \
libexecinfo-dev libretls-dev pcre2-dev llvm12-dev \
crystal shards
ENV CC=clang
ENV CXX=clang++
# Create a basic working directory to use for code.
RUN mkdir /opt/code
WORKDIR /opt/code
##
# Build stage: outputs an alpine image that contains a working Savi compiler
# (this image is used only as a precursor to the release stage)
FROM alpine:3.15 as build
# Install build tools, Pony dependencies, LLVM libraries, and Crystal.
# This line is kept intentionally the same as it was for the dev stage,
# so that it can share the same docker image layer cache entry.
RUN apk add --no-cache --update \
alpine-sdk coreutils linux-headers clang-dev lld \
valgrind perl \
libexecinfo-dev libretls-dev pcre2-dev \
llvm12-dev llvm12-static \
crystal shards
ENV CC=clang
ENV CXX=clang++
COPY --from=dev /usr/lib/libponyrt.bc \
/usr/lib/
COPY --from=dev /usr/lib/crystal/core/llvm/ext/llvm_ext.o \
/usr/lib/crystal/core/llvm/ext/
RUN mkdir /opt/savi
WORKDIR /opt/savi
COPY Makefile main.cr /opt/savi/
COPY lib /opt/savi/lib
COPY src /opt/savi/src
RUN make bin/savi
##
# Release stage: outputs a minimal alpine image with a working Savi compiler
# (this image is made available on DockerHub for download)
FROM alpine:3.15 as release
# Install runtime dependencies of the compiler.
RUN apk add --no-cache --update \
llvm11-libs gc pcre gcc clang lld libgcc libevent musl-dev libexecinfo-dev
RUN mkdir /opt/code
WORKDIR /opt/code
COPY --from=dev /usr/lib/libponyrt.bc \
/usr/lib/
COPY packages /opt/savi/packages
COPY --from=build bin/savi /bin/savi
ENTRYPOINT ["/bin/savi"]