Last active
January 30, 2020 10:22
-
-
Save rizo/d73c0bacc5446eeb75ebe0e985d6d301 to your computer and use it in GitHub Desktop.
Dockerfile for esy projects.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build image | |
FROM node:10.13-alpine as build | |
# Prepare the environment to install esy. | |
RUN apk add --no-cache \ | |
ca-certificates wget \ | |
bash curl perl-utils \ | |
git patch gcc g++ musl-dev make m4 | |
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub | |
RUN wget -q https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk | |
RUN apk add --no-cache glibc-2.28-r0.apk | |
ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib | |
RUN npm install -g --unsafe-perm [email protected] | |
RUN esy --version | |
WORKDIR /root | |
# Copy _only_ project description files. | |
COPY --chown=root:nogroup package.json esy.lock /root/ | |
# If you have sub-packages referenced with `link` in `package.json` add them here. | |
# This is compatible with dune's composable (ie monorepo) builds. | |
#RUN mkdir -p /root/some-sub-package | |
#COPY --chown=root:nogroup some-sub-package/package.json some-sub-package/esy.lock /root/some-sub-package/ | |
# Install and build the dependencies. | |
# In this case `esy build` will only build the dependencies from the package description because we | |
# haven't copied any project source and dune files. | |
RUN esy install | |
RUN esy build | |
# Add the full project tree with sources and dune files. | |
# This will build the actual project and reuse the prebuilt dependencies from the previous step. | |
COPY --chown=root:nogroup . /root/ | |
RUN esy build | |
# We install all public libs/bins for export. | |
RUN esy dune install --prefix=/root/_export | |
# Run image | |
FROM alpine:3.6 | |
WORKDIR /mnt/local | |
ENV PATH /mnt/local/bin:$PATH | |
# Copy the exported files from the build stage. | |
COPY --from=build /root/_export /mnt/local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment