Devops stuff
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ target
|
||||
.DS_Store
|
||||
webui/src/wasm
|
||||
webui/data
|
||||
.env
|
||||
|
||||
50
Dockerfile
Normal file
50
Dockerfile
Normal 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
12
docker-compose.yml
Normal 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
|
||||
43
shell.nix
Normal file
43
shell.nix
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
|
||||
let
|
||||
# First, select the rust toolchain attribute set from pkgs.
|
||||
# This set contains cargo, rustc, rust-std, rust-src, etc.
|
||||
# Using `pkgs.rust-toolchain` will select the default stable toolchain.
|
||||
rust-toolchain = pkgs.rust-toolchain;
|
||||
in
|
||||
pkgs.mkShell {
|
||||
# nativeBuildInputs are tools you run on your machine during development.
|
||||
nativeBuildInputs = with pkgs; [
|
||||
# 1. Add the main toolchain components (cargo, rustc).
|
||||
rust-toolchain
|
||||
|
||||
# 2. Add the Rust standard library for our specific WebAssembly target.
|
||||
# We get `rust-std` from the `rust-toolchain` set we defined above
|
||||
# to guarantee version consistency.
|
||||
(rust-toolchain.rust-std.override {
|
||||
targets = [ "wasm32-unknown-unknown" ];
|
||||
})
|
||||
|
||||
# 3. Add the other necessary tools.
|
||||
wasm-bindgen-cli
|
||||
bun
|
||||
clang # Recommended linker for wasm on NixOS
|
||||
pkg-config
|
||||
openssl
|
||||
];
|
||||
|
||||
# Environment variables that will be set when you enter the shell.
|
||||
shellHook = ''
|
||||
# Set the linker for the wasm target to avoid potential issues.
|
||||
export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_LINKER="${pkgs.clang}/bin/clang"
|
||||
|
||||
# Set the path to the Rust standard library source code.
|
||||
# This is used by tools like rust-analyzer for "go to definition", etc.
|
||||
export RUST_SRC_PATH="${rust-toolchain}/lib/rustlib/src/rust/library"
|
||||
|
||||
echo "✅ Nix shell is ready with Rust (wasm target), wasm-bindgen, and Bun."
|
||||
'';
|
||||
}
|
||||
8
webui/.env_dist
Normal file
8
webui/.env_dist
Normal 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
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user