Skip to content

Commit

Permalink
Add dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenhuyn committed Sep 18, 2024
1 parent cae2284 commit 491b2a8
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Stage 1: Build the Rust code to WASM
FROM rust:latest AS builder

# Install wasm-pack
RUN cargo install wasm-pack

# Set the working directory to /cubeway inside the container
WORKDIR /cubeway

# Copy the Rust manifest files into the container
COPY cubeway/Cargo.toml cubeway/Cargo.lock ./

# Copy the Rust source code into the container
COPY cubeway/src ./src

# Build the WASM package and output it to /app/pkg
RUN wasm-pack build --target web --out-dir /pkg

# Stage 2: Build the frontend
FROM node:16-alpine AS frontend

# Set the working directory to /app inside the container
WORKDIR /app

# Copy package.json and package-lock.json into the container
COPY app/package*.json ./

# Install npm dependencies
RUN npm ci

# Copy the rest of your frontend code into the container
COPY app/. ./

# Copy the WASM output from the builder stage into the frontend's pkg directory
COPY --from=builder /pkg ../cubeway/pkg

# Build the frontend assets
RUN npm run build

# Stage 3: Serve the built files with simple-http-server
FROM rust:latest AS server

# Install simple-http-server
RUN cargo install simple-http-server

# Set the working directory to /app/dist inside the container
WORKDIR /app/dist

# Copy the built frontend files from the frontend stage
COPY --from=frontend /app/dist ./
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "80:80"

0 comments on commit 491b2a8

Please sign in to comment.