Skip to content

Commit 3b4de5d

Browse files
committed
WIP
1 parent 13b48a6 commit 3b4de5d

File tree

5 files changed

+156
-231
lines changed

5 files changed

+156
-231
lines changed

.dockerignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
target/
22
Dockerfile
3-
Dockerfile_FE
43
docker-compose.yml
54
.dockerignore
65
cli/bin
@@ -16,7 +15,7 @@ tools/heartbeats-processor/*.db
1615
!tools/heartbeats-processor/.sqlx/
1716

1817
# Will be copied on demand in the Docker image, if necessary
19-
circuit-blobs
18+
# circuit-blobs
2019

2120
# GH workflows
2221
.github

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
# Rust
44
# This should be in line with the verison in:
5-
# - Makefile
6-
# - ./github/workflows/docs.yaml
7-
# - ./github/workflows/fmt.yaml
8-
# - ./github/workflows/lint.yaml
5+
# - Makefile (this file)
6+
# - .github/workflows/ci.yaml
7+
# - .github/workflows/fmt.yaml
8+
# - .github/workflows/lint.yaml
9+
# - frontend/Dockerfile
910
NIGHTLY_RUST_VERSION = "nightly"
1011

1112
# Docker

frontend/Dockerfile

Lines changed: 96 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,116 @@
1-
# Doesn't matter what we put here - it get's overwritten by the docker \
2-
# build command
3-
FROM node:23 AS build_image
1+
# =============================================================================
2+
# Mina Frontend Docker Image
3+
# =============================================================================
4+
#
5+
# This Dockerfile creates a production-ready Apache HTTP server image that serves
6+
# the Mina frontend application with pre-built WebAssembly (WASM) components.
7+
#
8+
# IMAGE STAGES:
9+
# 1. build_frontend - Compiles Angular frontend application
10+
# 2. build_wasm - Builds WebAssembly files for web node functionality
11+
# 3. wasm_files - Extracts only WASM artifacts (size optimization)
12+
# 4. final - Apache HTTP server with frontend and WASM assets
13+
#
14+
# FEATURES:
15+
# - Multi-stage build for optimized image size
16+
# - Pre-built WASM files for Mina web node
17+
# - Environment-specific configuration support
18+
# - Caching optimization for web assets
19+
# - WebRTC signaling configuration
20+
#
21+
# BUILD ARGUMENTS:
22+
# BUILD_CONFIGURATION - Angular build configuration (default: production)
23+
#
24+
# USAGE:
25+
# # Build frontend image
26+
# docker build -t mina-frontend .
27+
#
28+
# # Run with webnode environment
29+
# docker run -p 80:80 -e MINA_FRONTEND_ENVIRONMENT=webnode mina-frontend
30+
#
31+
# =============================================================================
32+
33+
# Build arguments
434
ARG BUILD_CONFIGURATION=production
5-
WORKDIR /app
6-
COPY . .
35+
36+
# Build stage for Angular frontend
37+
FROM node:23 AS build_frontend
38+
ARG BUILD_CONFIGURATION
39+
WORKDIR /app/frontend
40+
COPY frontend/ .
741
RUN npm install && \
842
node_modules/.bin/ng build --configuration \
943
${BUILD_CONFIGURATION} && \
1044
npm prune --production && \
11-
echo "---------- USING APACHE ----------"
45+
echo "---------- FRONTEND BUILD COMPLETE ----------"
46+
47+
# Build stage for WASM files
48+
FROM rust:latest AS build_wasm
49+
# IMPORTANT: The nightly version should match the version specified in:
50+
# - Makefile (NIGHTLY_RUST_VERSION)
51+
# - .github/workflows/ci.yaml
52+
# - .github/workflows/fmt.yaml
53+
# - .github/workflows/lint.yaml
54+
# - frontend/Dockerfile (this file)
55+
56+
# Install system dependencies required for building WASM
57+
RUN apt-get update && \
58+
apt-get install -y --no-install-recommends \
59+
build-essential \
60+
libssl-dev \
61+
pkg-config \
62+
protobuf-compiler \
63+
sqlite3 && \
64+
rm -rf /var/lib/apt/lists/*
65+
66+
# Install Rust nightly and WASM target
67+
RUN rustup toolchain install nightly && \
68+
rustup default nightly && \
69+
rustup target add wasm32-unknown-unknown && \
70+
cargo install wasm-bindgen-cli
1271

72+
WORKDIR /app
73+
COPY . .
74+
RUN make build-wasm && \
75+
echo "---------- WASM BUILD COMPLETE ----------"
1376

77+
# Extract WASM files stage
78+
FROM scratch AS wasm_files
79+
COPY --from=build_wasm /app/node/web/pkg /pkg
80+
81+
# Circuit files stage
82+
FROM alpine:latest AS circuit_files
83+
WORKDIR /circuit-blobs
84+
COPY circuit-blobs/3.0.1devnet/ .
85+
# Remove the symbolic link that might cause issues
86+
RUN rm -f tests
87+
88+
# Final Apache image
1489
FROM httpd:2.4
1590

1691
# hadolint ignore=DL3008
1792
RUN apt-get update && \
1893
apt-get install -y --no-install-recommends curl && \
1994
rm -rf /var/lib/apt/lists/*
2095

21-
COPY --from=BUILD_IMAGE /app/dist/frontend/browser \
96+
# Copy frontend assets
97+
COPY --from=build_frontend /app/frontend/dist/frontend/browser \
2298
/usr/local/apache2/htdocs/
23-
COPY --from=BUILD_IMAGE /app/httpd.conf \
99+
COPY --from=build_frontend /app/frontend/httpd.conf \
24100
/usr/local/apache2/conf/httpd.conf
25101

26-
COPY docker/startup.sh /usr/local/bin/startup.sh
27-
RUN chmod +x /usr/local/bin/startup.sh
102+
# Copy WASM files to webnode assets directory
103+
COPY --from=wasm_files /pkg \
104+
/usr/local/apache2/htdocs/assets/webnode/pkg
105+
106+
# Copy circuit files for webnode
107+
RUN mkdir -p /usr/local/apache2/htdocs/assets/webnode/circuit-blobs/3.0.1devnet
108+
COPY --from=circuit_files /circuit-blobs/ \
109+
/usr/local/apache2/htdocs/assets/webnode/circuit-blobs/3.0.1devnet/
28110

29-
ENTRYPOINT ["/usr/local/bin/startup.sh"]
111+
# Add labels for image metadata
112+
LABEL mina.circuit-files-included="true"
113+
LABEL mina.image-type="frontend"
114+
LABEL mina.components="angular,wasm,circuits"
30115

31116
CMD ["httpd-foreground"]

frontend/docker/startup.sh

Lines changed: 0 additions & 212 deletions
This file was deleted.

0 commit comments

Comments
 (0)