graphql-engine/server/packaging/Dockerfile
Anon Ray 9d2d158532 server: build now is multi-stage builds (fix #29)
- Change the build flow to use docker multi-stage builds
2018-07-02 16:40:13 +00:00

27 lines
914 B
Docker

ARG stack_resolver
ARG packager_version
# Stage 1: build the application
FROM fpco/stack-build:${stack_resolver} as builder
ARG stack_flags=""
ARG build_flags=""
ARG project="graphql-engine"
RUN mkdir /build
COPY . /build/
WORKDIR /build
RUN stack --system-ghc ${stack_flags} build ${build_flags}
RUN cp $(stack --system-ghc path --dist-dir)/build/${project}/${project} /build
# Stage 2: package the app into a busybox rootfs, strip, compress etc.
FROM hasura/graphql-engine-packager:${packager_version} as packager
ARG project="graphql-engine"
RUN mkdir -p /packaging/build/rootfs
COPY --from=builder /build/${project} /root/
RUN /build.sh ${project} | tar -xC /packaging/build/rootfs
RUN strip --strip-unneeded /packaging/build/rootfs/bin/${project}
RUN upx /packaging/build/rootfs/bin/${project}
# Stage 3: copy the rootfs into a scratch container
FROM scratch
COPY --from=packager /packaging/build/rootfs /