-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (28 loc) · 863 Bytes
/
Dockerfile
File metadata and controls
40 lines (28 loc) · 863 Bytes
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
# Stage 1: Build the compiler
FROM node:20-slim AS builder
RUN apt-get update && apt-get install -y clang make g++
WORKDIR /build
COPY Makefile .
COPY src ./src
# Build the compiler (produces /build/rox)
RUN make
# Run tests in the builder environment (which has make/clang/g++)
COPY test.sh .
COPY test ./test
RUN chmod +x test.sh && ./test.sh
# Stage 2: Runtime environment
FROM node:20-slim
# Install runtime dependencies (clang is needed because 'rox' invokes it)
RUN apt-get update && apt-get install -y clang && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy only the compiled binary from the builder stage
COPY --from=builder /build/rox .
# Copy web server
COPY web ./web
# Install web dependencies
WORKDIR /app/web
RUN npm install
# Expose port
EXPOSE 3000
# Start server (must run from /app/web so it finds ../rox)
CMD ["node", "server.js"]