Devops stuff
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ target
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
webui/src/wasm
|
webui/src/wasm
|
||||||
webui/data
|
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
|
||||||
31
shell.nix
Normal file
31
shell.nix
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
pkgs ? import <nixpkgs> { },
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
rust-toolchain = pkgs.rust-bin.stable."1.73.0".default;
|
||||||
|
|
||||||
|
rust-with-wasm-target = rust-toolchain.override {
|
||||||
|
targets = [ "wasm32-unknown-unknown" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
rust-with-wasm-target
|
||||||
|
|
||||||
|
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"
|
||||||
|
echo "Nix shell is ready with Cargo, 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 = {
|
export const SAVE_CONFIG = {
|
||||||
ENABLE_SAVE: true,
|
ENABLE_SAVE: process.env.ENABLE_SAVE === 'true' || true,
|
||||||
SAVE_SECRET: "save",
|
SAVE_SECRET: process.env.SAVE_SECRET || "save",
|
||||||
|
|
||||||
SAVE_DIRECTORY: "./data/scripts",
|
SAVE_DIRECTORY: process.env.SAVE_DIRECTORY || "./data/scripts",
|
||||||
MAX_FILENAME_LENGTH: 32,
|
MAX_FILENAME_LENGTH: parseInt(process.env.MAX_FILENAME_LENGTH || "32"),
|
||||||
FILENAME_REGEX: /^[a-zA-Z0-9_\s-]+$/,
|
FILENAME_REGEX: /^[a-zA-Z0-9_\s-]+$/,
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
Reference in New Issue
Block a user