From 523b3fc9296858bc501688de1a40309f305509be Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 10 Oct 2025 00:58:37 +0200 Subject: [PATCH] Add DevContainer setup for `auth-rs` --- .devcontainer/Dockerfile | 22 ++++++++++++++++ .devcontainer/devcontainer.json | 36 ++++++++++++++++++++++++++ .devcontainer/docker-compose.yml | 43 ++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..0464f3c --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,22 @@ +FROM mcr.microsoft.com/devcontainers/base:bookworm + +# Install Rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile default --component rustfmt,clippy \ + && echo 'source $HOME/.cargo/env' >> $HOME/.bashrc + +# Install Node.js LTS +RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ + && apt-get install -y nodejs \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Install Bun +RUN curl -fsSL https://bun.sh/install | bash \ + && echo 'export BUN_INSTALL="$HOME/.bun"' >> $HOME/.bashrc \ + && echo 'export PATH="$BUN_INSTALL/bin:$PATH"' >> $HOME/.bashrc + +ENV CARGO_HOME=/root/.cargo +ENV RUSTUP_HOME=/root/.rustup +ENV PATH="/root/.cargo/bin:/root/.bun/bin:${PATH}" +ENV BUN_INSTALL=/root/.bun + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..447d5c6 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,36 @@ +{ + "name": "auth-rs DevContainer", + "dockerComposeFile": [ + "docker-compose.yml" + ], + "service": "dev", + "workspaceFolder": "/workspaces/auth-rs", + "customizations": { + "vscode": { + "settings": { + "editor.formatOnSave": true, + "rust-analyzer.checkOnSave.command": "clippy" + }, + "extensions": [ + "rust-lang.rust-analyzer", + "serayuzgur.crates", + "tamasfe.even-better-toml", + "svelte.svelte-vscode", + "esbenp.prettier-vscode", + "dbaeumer.vscode-eslint" + ] + } + }, + "forwardPorts": [3000, 8000, 27017], + "portsAttributes": { + "3000": { "label": "Frontend" }, + "8000": { "label": "Backend" }, + "27017": { "label": "MongoDB" } + }, + "postCreateCommand": "bun install", + "remoteEnv": { + "ROCKET_ADDRESS": "0.0.0.0", + "ROCKET_DATABASES": "{auth-rs-db={url=\"mongodb://mongodb:27017\"}}", + "PUBLIC_API_URL": "http://localhost:8000/api" + } +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..afa26b5 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,43 @@ +services: + dev: + build: + context: . + dockerfile: Dockerfile + image: localhost/auth-rs-dev:latest + container_name: auth-rs-dev + volumes: + - ..:/workspaces/auth-rs:cached + command: sleep infinity + networks: + - devnet + depends_on: + mongodb: + condition: service_healthy + environment: + - ROCKET_ADDRESS=0.0.0.0 + - ROCKET_DATABASES={auth-rs-db={url="mongodb://mongodb:27017"}} + - PUBLIC_API_URL=http://localhost:8000/api + ports: + - "3000:3000" + - "8000:8000" + + mongodb: + image: mongo:latest + container_name: auth-rs-dev-mongodb + volumes: + - mongodb_data:/data/db + healthcheck: + test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s + networks: + - devnet + +volumes: + mongodb_data: + +networks: + devnet: + driver: bridge