Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"onAutoForward": "silent"
}
},
"updateContentCommand": "bin/setup && bin/rails db:test:prepare RAILS_ENV=test",
"postCreateCommand": ".devcontainer/postCreateCommand-init.sh",
"postAttachCommand": ".devcontainer/postAttachCommand-init.sh",
"customizations": {
Expand Down
8 changes: 3 additions & 5 deletions .devcontainer/postAttachCommand-init.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/usr/bin/env bash

if [ -n "$CODESPACE_NAME" ]; then
if [ -n "$CODESPACE_NAME" ] || [ -n "$ONA_ENVIRONMENT_NAME" ]; then
echo "Running updates"

# Github Codespace prebuild caches the codebase.
# This means depending on the time the Codespace is created,
# Github Codespace/Ona prebuild caches the codebase.
# This means depending on the time the environment is created,
# it may not be on latest commit with latest dependency changes
#
# See https://github.com/orgs/community/discussions/58172

if git fetch origin "$(git rev-parse --abbrev-ref HEAD)" && git diff --quiet "HEAD..origin/$(git rev-parse --abbrev-ref HEAD)" ;then
echo "Branch is already up to date"
Expand Down
5 changes: 5 additions & 0 deletions .devcontainer/postCreateCommand-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ if [ -n "$CODESPACE_NAME" ]; then
echo APP_DOMAIN="${CODESPACE_NAME}-3000.app.github.dev" >> .env
echo APP_PROTOCOL=https:// >> .env
echo COMMUNITY_NAME="DEV(codespace)" >> .env
elif [ -n "$ONA_ENVIRONMENT_NAME" ]; then
echo "Updating .env file with Ona specific values"
echo APP_DOMAIN="${ONA_ENVIRONMENT_NAME}-3000.app.ona.dev" >> .env
echo APP_PROTOCOL=https:// >> .env
echo COMMUNITY_NAME="DEV(Ona)" >> .env
fi
50 changes: 50 additions & 0 deletions .ona/automations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
tasks:
install-dependencies:
name: Install dependencies
command: |
echo "Installing Ruby dependencies..."
bundle install
echo "Installing Node.js dependencies..."
yarn install
echo "Setting up database..."
bin/setup
echo "Preparing test database..."
bin/rails db:test:prepare RAILS_ENV=test
triggeredBy:
- postDevcontainerStart
- manual

setup-environment:
name: Setup environment
command: |
if [ ! -f .env ]; then
echo "Creating .env file from sample..."
cp .env_sample .env
fi

# Update .env with Ona-specific values
if [ -n "$ONA_ENVIRONMENT_NAME" ]; then
echo "Updating .env file with Ona-specific values..."
echo "APP_DOMAIN=\"${ONA_ENVIRONMENT_NAME}-3000.app.ona.dev\"" >> .env
echo 'APP_PROTOCOL="https://"' >> .env
echo 'COMMUNITY_NAME="DEV(Ona)"' >> .env
fi

echo "Environment setup complete!"
triggeredBy:
- postDevcontainerStart
- manual

start-services:
name: Start development services
command: |
echo "Starting development services..."
dip up web
triggeredBy:
- manual

verify-setup:
name: Verify environment setup
command: .ona/verify-setup.sh
triggeredBy:
- manual
76 changes: 76 additions & 0 deletions .ona/verify-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash

echo "🔍 Verifying Ona environment setup..."

# Check if we're in an Ona environment
if [ -n "$ONA_ENVIRONMENT_NAME" ]; then
echo "✅ Running in Ona environment: $ONA_ENVIRONMENT_NAME"
else
echo "⚠️ Not running in Ona environment (ONA_ENVIRONMENT_NAME not set)"
fi

# Check if .env file exists
if [ -f .env ]; then
echo "✅ .env file exists"

# Check for Ona-specific configurations
if grep -q "app.ona.dev" .env; then
echo "✅ Ona domain configuration found"
else
echo "⚠️ Ona domain configuration not found in .env"
fi
else
echo "❌ .env file not found"
fi

# Check if database is accessible
if command -v psql >/dev/null 2>&1; then
if psql -h postgres -U postgres -d postgres -c "SELECT 1;" >/dev/null 2>&1; then
echo "✅ PostgreSQL database is accessible"
else
echo "❌ PostgreSQL database is not accessible"
fi
else
echo "⚠️ psql command not available"
fi

# Check if Redis is accessible
if command -v redis-cli >/dev/null 2>&1; then
if redis-cli -h redis ping >/dev/null 2>&1; then
echo "✅ Redis is accessible"
else
echo "❌ Redis is not accessible"
fi
else
echo "⚠️ redis-cli command not available"
fi

# Check if Ruby dependencies are installed
if [ -d "vendor/bundle" ]; then
echo "✅ Ruby dependencies are installed"
else
echo "❌ Ruby dependencies are not installed"
fi

# Check if Node.js dependencies are installed
if [ -d "node_modules" ]; then
echo "✅ Node.js dependencies are installed"
else
echo "❌ Node.js dependencies are not installed"
fi

# Check if database is set up
if [ -f "db/schema.rb" ]; then
echo "✅ Database schema exists"
else
echo "⚠️ Database schema not found (may need to run migrations)"
fi

echo ""
echo "🎯 Next steps:"
echo "1. If you see any ❌ errors, run: ona automation run setup-environment"
echo "2. If dependencies are missing, run: ona automation run install-dependencies"
echo "3. To start the development server: ona automation run start-services"
echo "4. Or manually: dip up web"
echo ""
echo "📚 For more help, see ONA_README.md"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ A more complete overview of our stack is available in
To **launch Forem in Gitpod**, navigate to
[https://gitpod.io/#https://github.com/{your_github_username}/forem](https://gitpod.io/#https://github.com/{your_github_username}/forem).

To **launch Forem in Ona** (formerly Gitpod), the project is fully configured for Ona development environments. Simply open the project in Ona and the environment will be automatically configured with all necessary services and dependencies.

### Installation Documentation

Please see our installation guides:
Expand Down
Loading