-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathDockerfile
46 lines (38 loc) · 1.56 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
FROM ghcr.io/graalvm/graalvm-ce:java11-21.1.0 as builder
# Install native-image
RUN gu install native-image
# Install sbt
RUN curl -L https://www.scala-sbt.org/sbt-rpm.repo > /etc/yum.repos.d/sbt-rpm.repo && \
microdnf install -y sbt
# Static image requirements
RUN mkdir /staticlibs && \
curl -L -o musl.tar.gz https://musl.libc.org/releases/musl-1.2.1.tar.gz && \
mkdir musl && tar -xvzf musl.tar.gz -C musl --strip-components 1 && cd musl && \
./configure --disable-shared --prefix=/staticlibs && \
make && make install && \
cd / && rm -rf /muscl && rm -f /musl.tar.gz && \
cp /usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a /staticlibs/lib/
ENV PATH="$PATH:/staticlibs/bin"
ENV CC="musl-gcc"
RUN curl -L -o zlib.tar.gz https://zlib.net/zlib-1.2.11.tar.gz && \
mkdir zlib && tar -xvzf zlib.tar.gz -C zlib --strip-components 1 && cd zlib && \
./configure --static --prefix=/staticlibs && \
make && make install && \
cd / && rm -rf /zlib && rm -f /zlib.tar.gz
# Copy the build files
COPY . /build
WORKDIR /build
# Build the native image
RUN sbt clean compile fullOptJS
RUN sbt server/graalvm-native-image:packageBin
RUN rm static/js/client.js.map
RUN curl -L -o docker-latest.tgz http://get.docker.com/builds/Linux/x86_64/docker-latest.tgz
RUN tar -xvzf docker-latest.tgz
# Copy the native image to an empty container
FROM scratch
COPY --from=builder /build/server/target/graalvm-native-image/server /server
COPY --from=builder /build/static /static
COPY --from=builder /build/docker/docker /docker
ENV PATH "/"
EXPOSE 8080
ENTRYPOINT [ "/server" ]