Skip to content

Commit

Permalink
Add sail (#386)
Browse files Browse the repository at this point in the history
* Setup sail

* feat(devcontainer): rename workspace

* feat(vite): add host

* Lint

* feat(devcontainer): remove sail alias

---------

Co-authored-by: Simon Ostendorf <[email protected]>
  • Loading branch information
TitusKirch and simonostendorf authored Aug 23, 2023
1 parent 18d2338 commit de2802d
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 76 deletions.
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// https://aka.ms/devcontainer.json
{
"name": "Laravel Sail",
"dockerComposeFile": [
"../docker-compose.yml"
],
"service": "laravel.test",
"workspaceFolder": "/var/www/html",
"customizations": {
"vscode": {
"extensions": [
// "mikestead.dotenv",
// "amiralizadeh9480.laravel-extra-intellisense",
// "ryannaddy.laravel-artisan",
// "onecentlin.laravel5-snippets",
// "onecentlin.laravel-blade"
],
"settings": {}
}
},
"remoteUser": "sail",
"postCreateCommand": "chown -R 1000:1000 /var/www/html"
// "forwardPorts": [],
// "runServices": [],
// "shutdownAction": "none",
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.10",
"laravel/sail": "^1.18",
"laravel/sail": "^1.23",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"phpunit/phpunit": "^10.3.2",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

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

135 changes: 71 additions & 64 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,74 @@
version: '3'
services:
web:
image: ghcr.io/fsr5-fhaachen/portals:latest
container_name: portals-web
restart: unless-stopped
depends_on:
- redis
- mariadb
environment:
APP_NAME: '${APP_NAME}'
APP_ENV: '${APP_ENV}' # set to local if you want to test without https
APP_KEY: '${APP_KEY}'
APP_DEBUG: '${APP_DEBUG}'
APP_URL: '${APP_URL}'
OCTANE_HTTPS: '${OCTANE_HTTPS}' # set to false if you want to test without https
OCTANE_WORKERS: '${OCTANE_WORKERS}'
OCTANE_MAX_REQUESTS: '${OCTANE_MAX_REQUESTS}'
LOG_CHANNEL: '${LOG_CHANNEL}'
LOG_LEVEL: '${LOG_LEVEL}'
DB_CONNECTION: '${DB_CONNECTION}'
DB_HOST: '${DB_HOST}'
DB_PORT: '${DB_PORT}'
DB_DATABASE: '${DB_DATABASE}'
DB_USERNAME: '${DB_USERNAME}'
DB_PASSWORD: '${DB_PASSWORD}'
BROADCAST_DRIVER: '${BROADCAST_DRIVER}'
CACHE_DRIVER: '${CACHE_DRIVER}'
FILESYSTEM_DRIVER: '${FILESYSTEM_DRIVER}'
QUEUE_CONNECTION: '${QUEUE_CONNECTION}'
SESSION_DRIVER: '${SESSION_DRIVER}'
SESSION_LIFETIME: '${SESSION_LIFETIME}'
REDIS_HOST: '${REDIS_HOST}'
REDIS_PASSWORD: '${REDIS_PASSWORD}'
REDIS_PORT: '${REDIS_PORT}'
ports:
- "8000:8000"
networks:
- portals
redis:
image: redis
container_name: portals-redis
restart: unless-stopped
command: redis-server --requirepass '${REDIS_PASSWORD}'
# ports:
# - "6379:6379"
networks:
- portals
mariadb:
image: mariadb
container_name: portals-mariadb
restart: unless-stopped
# ports:
# - "3306:3306"
environment:
MARIADB_DATABASE: '${DB_DATABASE}'
MARIADB_ROOT_PASSWORD: USE_SECRET_STRING_HERE
MARIADB_USER: '${DB_USERNAME}'
MARIADB_PASSWORD: '${DB_PASSWORD}'
volumes:
- portals_mariadb:/var/lib/mysql/
networks:
- portals
laravel.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:
- pgsql
- redis
pgsql:
image: 'postgres:15'
ports:
- '${FORWARD_DB_PORT:-5432}:5432'
environment:
PGPASSWORD: '${DB_PASSWORD:-secret}'
POSTGRES_DB: '${DB_DATABASE}'
POSTGRES_USER: '${DB_USERNAME}'
POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}'
volumes:
- 'sail-pgsql:/var/lib/postgresql/data'
- './vendor/laravel/sail/database/pgsql/create-testing-database.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql'
networks:
- sail
healthcheck:
test:
- CMD
- pg_isready
- '-q'
- '-d'
- '${DB_DATABASE}'
- '-U'
- '${DB_USERNAME}'
retries: 3
timeout: 5s
redis:
image: 'redis:alpine'
ports:
- '${FORWARD_REDIS_PORT:-6379}:6379'
volumes:
- 'sail-redis:/data'
networks:
- sail
healthcheck:
test:
- CMD
- redis-cli
- ping
retries: 3
timeout: 5s
networks:
portals:
sail:
driver: bridge
volumes:
portals_mariadb:
sail-pgsql:
driver: local
sail-redis:
driver: local
3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
<env name="DB_DATABASE" value="testing"/>
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
Expand Down
8 changes: 6 additions & 2 deletions resources/js/types/auto-imports.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Generated by 'unplugin-auto-import'
export {};
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
export {}
declare global {
const usePagesAsNavigation: typeof import("../composables/usePagesAsNavigation")["default"];
const usePlaceholderPerson: typeof import("../composables/usePlaceholderPerson")["default"];
Expand Down
12 changes: 6 additions & 6 deletions resources/js/types/components.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
import "@vue/runtime-core";
export {}

export {};

declare module "@vue/runtime-core" {
declare module "vue" {
export interface GlobalComponents {
2: typeof import("./../components/ui/Dl copy 2.vue")["default"];
AppButton: typeof import("./../components/app/Button.vue")["default"];
Expand Down
6 changes: 6 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export default defineConfig({
"@": "/resources/js",
},
},
server: {
host: '0.0.0.0',
hmr: {
host: 'localhost'
}
},
plugins: [
laravel({
input: ["resources/js/app.js"],
Expand Down

0 comments on commit de2802d

Please sign in to comment.