Skip to content

Commit 35e2261

Browse files
committed
get building and running in docker
1 parent 7ef0c6b commit 35e2261

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Stage 1: Builder
2+
# This stage installs all dependencies and builds the application.
3+
FROM debian:bookworm-slim AS builder
4+
5+
# Install essential build tools, clang, and nodejs for sass
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends \
8+
build-essential \
9+
clang-16 \
10+
llvm-16 \
11+
curl \
12+
pkg-config \
13+
libssl-dev \
14+
ca-certificates \
15+
nodejs \
16+
npm && \
17+
rm -rf /var/lib/apt/lists/*
18+
19+
# Install Rust and the wasm32 target
20+
ENV RUSTUP_HOME=/usr/local/rustup \
21+
CARGO_HOME=/usr/local/cargo \
22+
PATH=/usr/local/cargo/bin:$PATH
23+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable && \
24+
rustup target add wasm32-unknown-unknown
25+
26+
# Install Trunk and Dart Sass
27+
RUN cargo install trunk && \
28+
npm install -g sass
29+
30+
# Set environment variables for the Wasm C compiler, mimicking the Nix setup.
31+
# This tells Rust's build scripts to use clang-16 when compiling C code for Wasm.
32+
ENV CC_wasm32_unknown_unknown=clang-16
33+
ENV AR_wasm32_unknown_unknown=llvm-ar-16
34+
ENV CFLAGS_wasm32_unknown_unknown="-I/usr/lib/clang/16/include"
35+
36+
# Copy the application source code
37+
WORKDIR /app
38+
COPY . .
39+
40+
# Build the application
41+
RUN trunk build --release && \
42+
sh fix-links.sh
43+
44+
# Stage 2: Final Image
45+
# This stage creates a minimal image to serve the built static files.
46+
FROM nginx:1.27-alpine-slim
47+
48+
# Copy the built assets from the builder stage
49+
COPY --from=builder /app/dist /usr/share/nginx/html
50+
51+
# Expose port 80 and start Nginx
52+
EXPOSE 80
53+
CMD ["nginx", "-g", "daemon off;"]

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,19 @@ Simfony looks and feels like [Rust](https://www.rust-lang.org). Just how Rust co
88

99
## Develop the project
1010

11-
### Install dependencies
11+
### Using Docker
12+
13+
Build
14+
```
15+
docker build -t simplicity-webide .
16+
```
17+
18+
Run and naviate to `http://localhost:8080` in your web browser.
19+
```
20+
docker run -p 8080:80 simplicity-webide
21+
```
22+
23+
### Using Nix
1224

1325
First install nix.
1426

0 commit comments

Comments
 (0)