Devops stuff

This commit is contained in:
2025-11-03 17:08:44 -08:00
parent 30649488bb
commit bb02164b3d
6 changed files with 112 additions and 4 deletions

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@ target
.DS_Store
webui/src/wasm
webui/data
.env

50
Dockerfile Normal file
View File

@@ -0,0 +1,50 @@
# Stage 1: Build Rust WASM components
FROM rust:1.75 AS rust-builder
WORKDIR /app
# Install wasm-pack
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
# Copy Rust source code
COPY rust/ ./rust/
# Build WASM components
WORKDIR /app/rust/rhai-codemirror
RUN wasm-pack build --target web --out-dir "../../webui/src/wasm/rhai-codemirror"
WORKDIR /app/rust/runner
RUN wasm-pack build --target web --out-dir "../../webui/src/wasm/runner"
# Stage 2: Build and run Next.js application
FROM node:18-alpine AS app
WORKDIR /app
# Install Bun
RUN npm install -g bun
# Copy webui package files
COPY webui/package.json webui/bun.lock* ./webui/
# Install dependencies
WORKDIR /app/webui
RUN bun install --frozen-lockfile
# Copy webui source code
COPY webui/ ./
# Copy built WASM files from rust-builder stage
COPY --from=rust-builder /app/webui/src/wasm/ ./src/wasm/
# Build the application
RUN bun run build
# Create data directory for scripts
RUN mkdir -p ../data/scripts
# Expose port
EXPOSE 3000
# Start the application
CMD ["bun", "start"]

12
docker-compose.yml Normal file
View File

@@ -0,0 +1,12 @@
version: '3.8'
services:
webui:
build: .
ports:
- "3000:3000"
volumes:
- ./data/scripts:/app/data/scripts
env_file:
- .env
restart: unless-stopped

37
shell.nix Normal file
View File

@@ -0,0 +1,37 @@
{
pkgs ? import <nixpkgs> { },
}:
let
rust-channel = pkgs.rust-bin.stable."1.91.0";
rustPlatform = pkgs.makeRustPlatform {
cargo = rust-channel;
rustc = rust-channel;
};
rust-with-wasm-target = rustPlatform.override {
targets = [ "wasm32-unknown-unknown" ];
};
in
pkgs.mkShell {
buildInputs = with pkgs; [
rust-with-wasm-target
cargo
rustc
wasm-bindgen-cli
wasm-pack
bun
clang
pkg-config
openssl
];
shellHook = ''
# Set the linker for the wasm target to clang to avoid potential issues
export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_LINKER="${pkgs.clang}/bin/clang"
'';
}

8
webui/.env_dist Normal file
View File

@@ -0,0 +1,8 @@
# Script saving configuration
ENABLE_SAVE=true
SAVE_SECRET=save
SAVE_DIRECTORY=./data/scripts
MAX_FILENAME_LENGTH=32
# Next.js environment
NODE_ENV=production

View File

@@ -1,8 +1,8 @@
export const SAVE_CONFIG = {
ENABLE_SAVE: true,
SAVE_SECRET: "save",
ENABLE_SAVE: process.env.ENABLE_SAVE === 'true' || true,
SAVE_SECRET: process.env.SAVE_SECRET || "save",
SAVE_DIRECTORY: "./data/scripts",
MAX_FILENAME_LENGTH: 32,
SAVE_DIRECTORY: process.env.SAVE_DIRECTORY || "./data/scripts",
MAX_FILENAME_LENGTH: parseInt(process.env.MAX_FILENAME_LENGTH || "32"),
FILENAME_REGEX: /^[a-zA-Z0-9_\s-]+$/,
} as const;