From 3b6ecac72cd9b0cbbe4b32d6d7f3402285a46222 Mon Sep 17 00:00:00 2001 From: Yam C Borodetsky Date: Sat, 17 Jan 2026 18:23:01 +0500 Subject: [PATCH] remove: dev container configuration, documentation, and database setup scripts. --- .devcontainer.json | 80 -------------- docs/.vitepress/config.ts | 11 +- docs/dev-container.md | 49 --------- scripts/create-db.sh | 15 --- scripts/wait-for-db.sh | 215 -------------------------------------- 5 files changed, 1 insertion(+), 369 deletions(-) delete mode 100644 .devcontainer.json delete mode 100644 docs/dev-container.md delete mode 100755 scripts/create-db.sh delete mode 100755 scripts/wait-for-db.sh diff --git a/.devcontainer.json b/.devcontainer.json deleted file mode 100644 index b2841752..00000000 --- a/.devcontainer.json +++ /dev/null @@ -1,80 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node-postgres -{ - "name": "Bun & Postgres", - "dockerComposeFile": "docker-compose.yml", - "service": "app", - "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - // Features to add to the dev container. More info: https://containers.dev/features. - "features": { - "ghcr.io/devcontainers/features/github-cli:1": {}, - "ghcr.io/devcontainers-contrib/features/zsh-plugins:0": { - "plugins": "zsh-completions zsh-autosuggestions zsh-syntax-highlighting", - "omzPlugins": "https://github.com/zsh-users/zsh-completions.git https://github.com/zsh-users/zsh-autosuggestions.git https://github.com/zsh-users/zsh-syntax-highlighting.git" - }, - "ghcr.io/shyim/devcontainers-features/bun:0": {}, - "ghcr.io/itsmechlark/features/postgresql:1.5.0": {} - }, - "waitFor": "onCreateCommand", - "updateContentCommand": "bun i", - "postAttachCommand": { - "app": "bun dev", - "studio": "bun db:studio", - "docs": "bun docs" - }, - // "postCreateCommand": "bun db:migrate && bun db:seed", - "postCreateCommand": "./scripts/create-db.sh", - "customizations": { - "vscode": { - "extensions": [ - "biomejs.biome", - "ms-azuretools.vscode-docker", - "w0o0o.bun-scripts", - "oven.bun-vscode", - "antfu.browse-lite", - "mtxr.sqltools", - "mtxr.sqltools-driver-pg", - "bierner.markdown-preview-github-styles", - "Pandy.bun", - "github.vscode-github-actions", - "yzhang.markdown-all-in-one", - "Vue.volar" - ], - "settings": { - "editor.tabSize": 2, - "editor.insertSpaces": true, - "terminal.integrated.defaultProfile.linux": "zsh", - "[typescript]": { - "editor.defaultFormatter": "biomejs.biome" - }, - "[json]": { - "editor.defaultFormatter": "biomejs.biome" - } - } - } - }, - "portsAttributes": { - "3000": { - "label": "App", - "onAutoForward": "openPreview" - }, - "4173": { - "label": "Docs (Preview)" - }, - "4983": { - "label": "Studio" - }, - "5173": { - "label": "Docs" - }, - "5432": { - "label": "Database" - } - }, - "forwardPorts": [5432, 3000, 4983, 4173] - - // Configure tool-specific properties. - // "customizations": {}, - // Needed for bun install (for access to save .lockb). More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 21de8645..a00eeaaf 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -36,16 +36,7 @@ export default defineConfig({ ], collapsed: false, }, - { - text: 'Experimental', - items: [ - { - text: 'Developing in a Dev Container', - link: '/dev-container', - }, - ], - collapsed: true, - }, + { text: "Developer's Guide", link: 'https://github.com/bedtime-coders/bedstack/blob/main/CONTRIBUTING.md', diff --git a/docs/dev-container.md b/docs/dev-container.md deleted file mode 100644 index 2d9d364d..00000000 --- a/docs/dev-container.md +++ /dev/null @@ -1,49 +0,0 @@ -# Developing in a Dev Container - -This project provides partial support for developing in a [dev container](https://code.visualstudio.com/docs/remote/containers). We are still working on this feature, but once it is ready, it should make the onboarding process much easier. At that point, it would be **the recommended way to develop this project**. - -## Why use a dev container? - -The main reason to use a dev container is to **make the onboarding process as easy as possible**. With a dev container, you can get started with this project with just a few clicks. You don't need to install any dependencies on your machine, and you don't need to worry about setting up your environment. Everything is already set up for you. - -## Getting started - -### Prerequisites - -- [Visual Studio Code](https://code.visualstudio.com/) version 1.60.0 or higher. -- [Docker](https://www.docker.com/) version 20.10.8 or higher. -- [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension for Visual Studio Code. - -::: info -For now, you must change "file sharing implementation" from **VirtioFS** to **gRPC fuse** in the _Docker settings_. See [oven-sh/bun#4923](https://github.com/oven-sh/bun/issues/4923#issuecomment-1715677390) for more details. -::: - - - -::: info -For now, you must _rebuild_ the container using `⌘` `⇧` `P` - → `Dev Containers: Rebuild Container` after building the container the first time. See [#55](https://github.com/bedtime-coders/bedstack/issues/55) for details; PRs welcome. -::: - -### Setup - -1. **Clone the repository** - - ```sh - $ gh repo clone bedtime-coders/bedstack - $ cd bedstack - ``` - -2. **Open the project in a dev container** - - 1. Open the command palette (Cmd+Shift+P on macOS, Ctrl+Shift+P on Windows/Linux) and select **Remote-Containers: Open Folder in Container...**. - 2. Select the project folder. - 3. Wait for the container to build and open the project in a new window. - -3. :tada: **You're ready to go!** - -## What's Next? - -- Please report any issues you encounter with the dev container in [GitHub Issues, with the `devcontainers` label](https://github.com/bedtime-coders/bedstack/labels/devcontainers). diff --git a/scripts/create-db.sh b/scripts/create-db.sh deleted file mode 100755 index 34c8d9ee..00000000 --- a/scripts/create-db.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# Source .env file to get environment variables -source .env - -# TODO: find a fix for database ('medium') creation without having to rebuild - -# Run wait-for-db.sh with the sourced environment variables -# ./scripts/wait-for-db.sh db:5432 --strict --timeout=60 -- psql -h db -U ${POSTGRES_USER} -d ${POSTGRES_DB} -c 'SELECT 1;' - -# TODO: find a better way to wait for database ('medium') creation than waiting 10 seconds -sleep 10 - -bun db:migrate -bun db:seed diff --git a/scripts/wait-for-db.sh b/scripts/wait-for-db.sh deleted file mode 100755 index 6ca54a4a..00000000 --- a/scripts/wait-for-db.sh +++ /dev/null @@ -1,215 +0,0 @@ -#!/usr/bin/env bash - -# wait-for-db.sh modifies wait-for-it.sh to work with postgresql by waiting for a specific database to be ready -# see original: https://github.com/vishnubob/wait-for-it - -# Use this script to test if a given TCP host/port are available - -WAITFORIT_cmdname=${0##*/} - -echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } - -usage() -{ - cat << USAGE >&2 -Usage: - $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args] - -h HOST | --host=HOST Host or IP under test - -p PORT | --port=PORT TCP port under test - Alternatively, you specify the host and port as host:port - -s | --strict Only execute subcommand if the test succeeds - -q | --quiet Don't output any status messages - -t TIMEOUT | --timeout=TIMEOUT - Timeout in seconds, zero for no timeout - -- COMMAND ARGS Execute command with args after the test finishes -USAGE - exit 1 -} - -wait_for() -{ - if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then - echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" - else - echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout" - fi - WAITFORIT_start_ts=$(date +%s) - while : - do - if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then - nc -z $WAITFORIT_HOST $WAITFORIT_PORT - WAITFORIT_result=$? - else - (echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1 - WAITFORIT_result=$? - fi - if [[ $WAITFORIT_result -eq 0 ]]; then - WAITFORIT_end_ts=$(date +%s) - echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds" - break - fi - sleep 1 - done - return $WAITFORIT_result -} - -wait_for_wrapper() -{ - # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 - if [[ $WAITFORIT_QUIET -eq 1 ]]; then - timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & - else - timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & - fi - WAITFORIT_PID=$! - trap "kill -INT -$WAITFORIT_PID" INT - wait $WAITFORIT_PID - WAITFORIT_RESULT=$? - if [[ $WAITFORIT_RESULT -ne 0 ]]; then - echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" - fi - return $WAITFORIT_RESULT -} - -# process arguments -while [[ $# -gt 0 ]] -do - case "$1" in - *:* ) - WAITFORIT_hostport=(${1//:/ }) - WAITFORIT_HOST=${WAITFORIT_hostport[0]} - WAITFORIT_PORT=${WAITFORIT_hostport[1]} - shift 1 - ;; - --child) - WAITFORIT_CHILD=1 - shift 1 - ;; - -q | --quiet) - WAITFORIT_QUIET=1 - shift 1 - ;; - -s | --strict) - WAITFORIT_STRICT=1 - shift 1 - ;; - -h) - WAITFORIT_HOST="$2" - if [[ $WAITFORIT_HOST == "" ]]; then break; fi - shift 2 - ;; - --host=*) - WAITFORIT_HOST="${1#*=}" - shift 1 - ;; - -p) - WAITFORIT_PORT="$2" - if [[ $WAITFORIT_PORT == "" ]]; then break; fi - shift 2 - ;; - --port=*) - WAITFORIT_PORT="${1#*=}" - shift 1 - ;; - -t) - WAITFORIT_TIMEOUT="$2" - if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi - shift 2 - ;; - --timeout=*) - WAITFORIT_TIMEOUT="${1#*=}" - shift 1 - ;; - --) - shift - WAITFORIT_CLI=("$@") - break - ;; - --help) - usage - ;; - *) - echoerr "Unknown argument: $1" - usage - ;; - esac -done - -if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then - echoerr "Error: you need to provide a host and port to test." - usage -fi - -WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15} -WAITFORIT_STRICT=${WAITFORIT_STRICT:-0} -WAITFORIT_CHILD=${WAITFORIT_CHILD:-0} -WAITFORIT_QUIET=${WAITFORIT_QUIET:-0} - -# Check to see if timeout is from busybox? -WAITFORIT_TIMEOUT_PATH=$(type -p timeout) -WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH) - -WAITFORIT_BUSYTIMEFLAG="" -if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then - WAITFORIT_ISBUSY=1 - # Check if busybox timeout uses -t flag - # (recent Alpine versions don't support -t anymore) - if timeout &>/dev/stdout | grep -q -e '-t '; then - WAITFORIT_BUSYTIMEFLAG="-t" - fi -else - WAITFORIT_ISBUSY=0 -fi - -if [[ $WAITFORIT_CHILD -gt 0 ]]; then - wait_for - WAITFORIT_RESULT=$? - exit $WAITFORIT_RESULT -else - if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then - wait_for_wrapper - WAITFORIT_RESULT=$? - else - wait_for - WAITFORIT_RESULT=$? - fi -fi - -if [[ $WAITFORIT_CLI != "" ]]; then - if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then - echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess" - exit $WAITFORIT_RESULT - fi - exec "${WAITFORIT_CLI[@]}" -else - exit $WAITFORIT_RESULT -fi - -# wait for db -if [ "$WAITFORIT_TIMEOUT" -gt 0 ]; then - echo "wait-for-db.sh: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" -else - echo "wait-for-db.sh: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds" - - # Initialize variables for the loop - max_retries=5 - count=0 - - # Loop to retry database connection - while [[ $count -lt $max_retries ]] - do - PGPASSWORD=${POSTGRES_PASSWORD} psql -h $WAITFORIT_HOST -U ${POSTGRES_USER} -d ${POSTGRES_DB} -c 'SELECT 1;' &>/dev/null - exit_status=$? - if [ $exit_status -eq 0 ]; then - echo "wait-for-db.sh: database is ready" - exit 0 - fi - echo "wait-for-db.sh: database not ready yet. Retrying... ($((count+1))/$max_retries)" - ((count++)) - sleep 5 - done - - # If it reaches here, it means it failed to connect to the database after max_retries - echo "wait-for-db.sh: Failed to connect to database after $max_retries retries." - exit 1 -fi