forked from grain-lang/grain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-slim
44 lines (32 loc) · 1.24 KB
/
Dockerfile-slim
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
# This Dockerfile constructs a minimal environment in which Grain programs can be compiled.
# The environment is only meant to build Grain programs, not develop the compiler.
FROM ospencer/esy:alpine as esy
FROM node:18 as builder
LABEL name="Grain"
LABEL description="Grain CLI"
LABEL vcs-url="https://github.com/grain-lang/grain"
LABEL maintainer="team@grain-lang.org"
COPY . /grain
WORKDIR /grain
# esy does not currently ship linux/arm64 binaries, so we manually patch it in
# Install dependencies but don't allow esy's postinstall script to run
RUN npm ci --ignore-scripts
# This line is technically incorrect on amd64, but docker does not support
# conditional copies and the arm64 folder is ignored on amd64 anyway
COPY --from=esy /app/_release /grain/node_modules/esy/platform-linux-arm64
# Manually run esy's postinstall script
RUN cd node_modules/esy && npm run postinstall
# Necessary because we disabled scripts during the original install
RUN npm run prepare
# Build the compiler and CLI
RUN npm run compiler build \
# Remove build files
&& rm -rf compiler/_esy
FROM node:18-slim
COPY --from=builder /grain /grain
WORKDIR /grain
# Link CLI in new image
RUN npm run cli link
# Set up container environment
WORKDIR /
CMD [ "/bin/bash" ]