Skip to content

Commit

Permalink
Merge pull request #247 from tighten/feat/onboarding-sail
Browse files Browse the repository at this point in the history
Onboarding Sail (docker)
  • Loading branch information
gcavanunez authored Jun 7, 2024
2 parents e86fb6a + 40986dc commit 51b083e
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_SERVICE="ozzie.test"
APP_URL=https://ozzie.test
APP_TWITTER="tightenco"

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
npm-debug.log
yarn-error.log
.env
auth.json
/.phpunit.cache
/.phpunit.result.cache
.php_cs.cache
Expand Down
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

## Local Installation

### MacOS - Valet
1. Clone the repo (`git clone git@github.com:tighten/ozzie.git && cd ozzie`)
2. Install dependencies (`composer install && npm install`)
3. Run `valet secure` to use `https` for the local domain
Expand All @@ -18,13 +19,50 @@
- Application Name: `Local Ozzie`
- Homepage URL: `https://ozzie.test`
- Application Description: `Local Version of Ozzie`
- Authorization Callback URL: `http://ozzie.test/auth/callback`
- Authorization Callback URL: `https://ozzie.test/auth/callback`
4. Copy the example `.env` file: `cp .env.example .env` and modify its settings to match your local install, including the client ID and secret from the previous step
5. Run `php artisan key:generate`
6. Create a database (by default `.env` looks for one named `ozzie`) and run the migrations (`php artisan migrate`)
7. Fetch the projects list (into the database) by using the `projects:fetch` command. Alternatively, you can seed your `projects` table using a `projects.json` file at the root of the project (see below for more info).
9. Fetch all projects' stats for the first time using `stats:fetch`

### Sail - Docker

*ensure you have docker installed and running*

For the following steps, you'll need to have the `sail` command available. You can alias it by running:
```shell
alias sail='[ -f sail ] && sh sail || sh vendor/bin/sail'
```
[For more info around aliasing check this part of the docs](https://laravel.com/docs/10.x/sail#configuring-a-shell-alias)

1. Clone the repo (`git clone git@github.com:tighten/ozzie.git && cd ozzie`)
2. Install dependencies

```shell
docker run --rm \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/var/www/html" \
-w /var/www/html \
laravelsail/php82-composer:latest \
composer install --ignore-platform-reqs
```

```shell
sail npm install
```

3. Create a [GitHub OAuth Application](https://github.com/settings/developers). If you use Valet to serve your application locally, you can use the following settings:
- Application Name: `Local Ozzie`
- Homepage URL: `http://localhost`
- Application Description: `Local Version of Ozzie`
- Authorization Callback URL: `http://localhost/auth/callback`
4. Copy the example `.env` file: `cp .env.example .env` and modify its settings to match your local install, including the client ID and secret from the previous step
5. Run `sail artisan key:generate`
6. Run the migrations (`sail artisan migrate`)
7. Fetch the projects list (into the database) by using the `projects:fetch` command. Alternatively, you can seed your `projects` table using a `projects.json` file at the root of the project (see below for more info).
8. Fetch all projects' stats for the first time using `stats:fetch`
> Note: If you're not using a tool like Laravel Valet, run `php artisan serve` and visit your site at http://127.0.0.1:8000; you'll also want to modify your GitHub app settings to use http://127.0.0.1:8000 instead of http://ozzie.test
## Projects and Daily Caching
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
},
"require-dev": {
"fakerphp/faker": "^1.13",
"laravel/sail": "^1.29",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"pestphp/pest": "^2.33",
Expand Down
136 changes: 135 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
services:
ozzie.test:
build:
context: ./vendor/laravel/sail/runtimes/8.2
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.2/app
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
IGNITION_LOCAL_SITES_PATH: '${PWD}'
volumes:
- '.:/var/www/html'
networks:
- sail
depends_on:
- mysql
mysql:
image: 'mysql/mysql-server:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_HOST: '%'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- 'sail-mysql:/var/lib/mysql'
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
networks:
- sail
healthcheck:
test:
- CMD
- mysqladmin
- ping
- '-p${DB_PASSWORD}'
retries: 3
timeout: 5s
networks:
sail:
driver: bridge
volumes:
sail-mysql:
driver: local
2 changes: 1 addition & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default defineConfig(({ mode }) => {
laravel({
input: ['resources/ts/app.ts'],
refresh: true,
valetTls: envAppUrl.hostname,
valetTls: !envConfig?.parsed?.LARAVEL_SAIL ?? envAppUrl.hostname,
}),
vue({
template: {
Expand Down

0 comments on commit 51b083e

Please sign in to comment.