-
Notifications
You must be signed in to change notification settings - Fork 147
Improve Amp orb development workflow #1529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| if ! sudo docker info >/dev/null 2>&1; then | ||
| if systemctl cat amp-svc-docker-daemon.service >/dev/null 2>&1; then | ||
| amp orb service restart docker-daemon | ||
| else | ||
| amp orb service start docker-daemon --command 'sudo dockerd' | ||
| fi | ||
|
|
||
| for _ in $(seq 1 8); do | ||
| sudo docker info >/dev/null 2>&1 && break | ||
| sleep 1 | ||
| done | ||
| fi | ||
|
|
||
| sudo docker info >/dev/null | ||
| sudo docker compose up -d | ||
| amp orb services ensure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| echo "==> Updating Bun" | ||
| bun upgrade | ||
|
|
||
| if ! command -v docker >/dev/null 2>&1; then | ||
| echo "==> Installing Docker and Docker Compose" | ||
| sudo install -m 0755 -d /etc/apt/keyrings | ||
| sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc | ||
| sudo chmod a+r /etc/apt/keyrings/docker.asc | ||
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | | ||
| sudo tee /etc/apt/sources.list.d/docker.list >/dev/null | ||
| sudo apt-get update | ||
| sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | ||
| fi | ||
|
|
||
| if ! sudo docker info >/dev/null 2>&1; then | ||
| echo "==> Starting Docker" | ||
| if systemctl cat amp-svc-docker-daemon.service >/dev/null 2>&1; then | ||
| amp orb service restart docker-daemon | ||
| else | ||
| amp orb service start docker-daemon --command 'sudo dockerd' | ||
| fi | ||
|
|
||
| for _ in $(seq 1 30); do | ||
| sudo docker info >/dev/null 2>&1 && break | ||
| sleep 1 | ||
| done | ||
| sudo docker info >/dev/null | ||
| fi | ||
|
|
||
| if [ ! -f .env ]; then | ||
| echo "==> Creating local environment file" | ||
| cp -- .env.example .env | ||
| fi | ||
|
|
||
| echo "==> Building and starting development containers" | ||
| sudo docker compose up -d --build | ||
|
|
||
| echo "==> Building Vite client assets" | ||
| sudo docker compose exec -T web bin/vite build | ||
|
|
||
| echo "==> Preparing and seeding the development database" | ||
| sudo docker compose exec -T web bin/rails db:prepare db:seed | ||
|
|
||
| echo "==> Preparing the test database" | ||
| sudo docker compose exec -T web env RAILS_ENV=test bin/rails db:prepare | ||
|
|
||
| echo "==> Ensuring the Hackatime portal service is running" | ||
| amp orb services ensure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| services: | ||
| hackatime: | ||
| command: sudo docker compose up -d db && sudo env PUBLIC_URL="$PUBLIC_URL" docker compose --profile portal up --no-deps portal | ||
| port: 3001 | ||
| portal: | ||
| title: Hackatime | ||
| description: Use /__dev/log-me-in/test@example.com to sign in as the seeded development user. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,5 +82,6 @@ public/vite | |
|
|
||
| target.txt | ||
|
|
||
| .amp/ | ||
| .amp/* | ||
| !.amp/services.yaml | ||
| plans/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| class DevController < ApplicationController | ||
| before_action :ensure_development_environment | ||
|
|
||
| def index | ||
| render plain: <<~TEXT | ||
| Development endpoints: | ||
| GET /__dev/log-me-in/<email> | ||
| GET /__dev/log-me-out | ||
| TEXT | ||
| end | ||
|
|
||
| def log_me_in | ||
| email_address = EmailAddress.find_by(email: params[:email].downcase) | ||
| return render plain: "No local user has that email address.\n", status: :not_found unless email_address | ||
|
|
||
| reset_session | ||
| session[:user_id] = email_address.user_id | ||
| redirect_to root_path, notice: "Signed in as #{email_address.email}." | ||
| end | ||
|
|
||
| def log_me_out | ||
| reset_session | ||
| redirect_to dev_path, notice: "Signed out." | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def ensure_development_environment | ||
| raise ActionController::RoutingError, "Not Found" unless Rails.env.development? | ||
| end | ||
| end | ||
|
skyfallwastaken marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.