Skip to content

Commit a8e6fcb

Browse files
committed
add sail and an example laravel app for testing
1 parent 6aa2ff6 commit a8e6fcb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+12502
-0
lines changed

.env.example

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
APP_NAME=LaravelMultiFactorExampleApp
2+
APP_ENV=local
3+
APP_KEY=base64:ncRWo33+xwooigcNOmGoluSlIi/wLQeBdPNvjDx8c3M=
4+
APP_DEBUG=true
5+
APP_URL=http://multi-factor.test
6+
7+
APP_LOCALE=en
8+
APP_FALLBACK_LOCALE=en
9+
APP_FAKER_LOCALE=en_US
10+
11+
# Docker
12+
APP_SERVICE=app
13+
DOCKER_CONTAINER_NAME=multi-factor
14+
#DOCKER_PHP_VERSION=8.5
15+
16+
COMPOSE_PROJECT_NAME=laravel-multi-factor
17+
18+
APP_MAINTENANCE_DRIVER=file
19+
# APP_MAINTENANCE_STORE=database
20+
21+
PHP_CLI_SERVER_WORKERS=4
22+
23+
BCRYPT_ROUNDS=12
24+
25+
LOG_CHANNEL=stack
26+
LOG_STACK=single
27+
LOG_DEPRECATIONS_CHANNEL=null
28+
LOG_LEVEL=debug
29+
30+
DB_CONNECTION=mysql
31+
DB_HOST=laravel-multi-factor-mysql-1
32+
DB_PORT=3306
33+
DB_DATABASE=multi-factor
34+
DB_USERNAME=multi-factor
35+
DB_PASSWORD=multi-factor
36+
37+
SESSION_DRIVER=database
38+
SESSION_LIFETIME=120
39+
SESSION_ENCRYPT=false
40+
SESSION_PATH=/
41+
SESSION_DOMAIN=null
42+
43+
BROADCAST_CONNECTION=log
44+
FILESYSTEM_DISK=local
45+
QUEUE_CONNECTION=database
46+
47+
CACHE_STORE=database
48+
# CACHE_PREFIX=
49+
50+
MEMCACHED_HOST=127.0.0.1
51+
52+
REDIS_CLIENT=phpredis
53+
REDIS_HOST=127.0.0.1
54+
REDIS_PASSWORD=null
55+
REDIS_PORT=6379
56+
57+
MAIL_MAILER=log
58+
MAIL_SCHEME=null
59+
MAIL_HOST=127.0.0.1
60+
MAIL_PORT=2525
61+
MAIL_USERNAME=null
62+
MAIL_PASSWORD=null
63+
MAIL_FROM_ADDRESS="[email protected]"
64+
MAIL_FROM_NAME="${APP_NAME}"
65+
66+
AWS_ACCESS_KEY_ID=
67+
AWS_SECRET_ACCESS_KEY=
68+
AWS_DEFAULT_REGION=us-east-1
69+
AWS_BUCKET=
70+
AWS_USE_PATH_STYLE_ENDPOINT=false
71+
72+
VITE_APP_NAME="${APP_NAME}"

compose.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# For more information: https://laravel.com/docs/sail
2+
services:
3+
app:
4+
container_name: ${DOCKER_CONTAINER_NAME:-laravel_multi_factor}
5+
build:
6+
context: ./docker/${DOCKER_PHP_VERSION:-8.4}
7+
dockerfile: Dockerfile
8+
args:
9+
WWWGROUP: '${WWWGROUP}'
10+
image: sail-${DOCKER_PHP_VERSION:-8.4}/app
11+
extra_hosts:
12+
- 'host.docker.internal:host-gateway'
13+
environment:
14+
WWWUSER: '${WWWUSER}'
15+
LARAVEL_SAIL: 1
16+
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
17+
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
18+
volumes:
19+
- './exampleApp:/var/www/html'
20+
- './.env:/var/www/html/.env'
21+
- '.:/var/www/package'
22+
networks:
23+
- internal
24+
- shared
25+
depends_on:
26+
- mysql
27+
mysql:
28+
container_name: laravel-multi-factor-mysql-1
29+
image: 'mysql/mysql-server:8.0'
30+
environment:
31+
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
32+
MYSQL_ROOT_HOST: "%"
33+
MYSQL_DATABASE: '${DB_DATABASE:-laravel_multi_factor}'
34+
MYSQL_USER: '${DB_USERNAME}'
35+
MYSQL_PASSWORD: '${DB_PASSWORD}'
36+
MYSQL_ALLOW_EMPTY_PASSWORD: 1
37+
networks:
38+
- internal
39+
healthcheck:
40+
test: [ "CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}" ]
41+
retries: 3
42+
timeout: 5s
43+
networks:
44+
internal:
45+
internal: true
46+
shared:
47+
external: true

docker/8.4/Dockerfile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
FROM ubuntu:24.04
2+
3+
LABEL maintainer="Taylor Otwell"
4+
5+
ARG WWWGROUP
6+
ARG NODE_VERSION=22
7+
ARG MYSQL_CLIENT="mysql-client"
8+
ARG POSTGRES_VERSION=17
9+
10+
WORKDIR /var/www/html
11+
12+
ENV DEBIAN_FRONTEND=noninteractive
13+
ENV TZ=UTC
14+
ENV SUPERVISOR_PHP_COMMAND="/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80"
15+
ENV SUPERVISOR_PHP_USER="sail"
16+
17+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
18+
19+
RUN echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99custom && \
20+
echo "Acquire::http::No-Cache true;" >> /etc/apt/apt.conf.d/99custom && \
21+
echo "Acquire::BrokenProxy true;" >> /etc/apt/apt.conf.d/99custom
22+
23+
RUN apt-get update && apt-get upgrade -y \
24+
&& mkdir -p /etc/apt/keyrings \
25+
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python3 dnsutils librsvg2-bin fswatch ffmpeg nano \
26+
&& curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xb8dc7e53946656efbce4c1dd71daeaab4ad4cab6' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null \
27+
&& echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
28+
&& apt-get update \
29+
&& apt-get install -y php8.4-cli php8.4-dev \
30+
php8.4-pgsql php8.4-sqlite3 php8.4-gd \
31+
php8.4-curl php8.4-mongodb \
32+
php8.4-imap php8.4-mysql php8.4-mbstring \
33+
php8.4-xml php8.4-zip php8.4-bcmath php8.4-soap \
34+
php8.4-intl php8.4-readline \
35+
php8.4-ldap \
36+
php8.4-msgpack php8.4-igbinary php8.4-redis php8.4-swoole \
37+
php8.4-memcached php8.4-pcov php8.4-imagick php8.4-xdebug \
38+
&& curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer \
39+
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
40+
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
41+
&& apt-get update \
42+
&& apt-get install -y nodejs \
43+
&& npm install -g npm \
44+
&& npm install -g pnpm \
45+
&& npm install -g bun \
46+
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /etc/apt/keyrings/yarn.gpg >/dev/null \
47+
&& echo "deb [signed-by=/etc/apt/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
48+
&& curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/keyrings/pgdg.gpg >/dev/null \
49+
&& echo "deb [signed-by=/etc/apt/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt noble-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
50+
&& apt-get update \
51+
&& apt-get install -y yarn \
52+
&& apt-get install -y $MYSQL_CLIENT \
53+
&& apt-get install -y postgresql-client-$POSTGRES_VERSION \
54+
&& apt-get -y autoremove \
55+
&& apt-get clean \
56+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
57+
58+
RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.4
59+
60+
RUN userdel -r ubuntu
61+
RUN groupadd --force -g $WWWGROUP sail
62+
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
63+
64+
COPY start-container /usr/local/bin/start-container
65+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
66+
COPY php.ini /etc/php/8.4/cli/conf.d/99-sail.ini
67+
RUN chmod +x /usr/local/bin/start-container
68+
69+
EXPOSE 80/tcp
70+
71+
ENTRYPOINT ["start-container"]

docker/8.4/php.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[PHP]
2+
post_max_size = 100M
3+
upload_max_filesize = 100M
4+
variables_order = EGPCS
5+
pcov.directory = .

docker/8.4/start-container

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
if [ "$SUPERVISOR_PHP_USER" != "root" ] && [ "$SUPERVISOR_PHP_USER" != "sail" ]; then
4+
echo "You should set SUPERVISOR_PHP_USER to either 'sail' or 'root'."
5+
exit 1
6+
fi
7+
8+
if [ ! -z "$WWWUSER" ]; then
9+
usermod -u $WWWUSER sail
10+
fi
11+
12+
if [ ! -d /.composer ]; then
13+
mkdir /.composer
14+
fi
15+
16+
chmod -R ugo+rw /.composer
17+
18+
if [ $# -gt 0 ]; then
19+
if [ "$SUPERVISOR_PHP_USER" = "root" ]; then
20+
exec "$@"
21+
else
22+
exec gosu $WWWUSER "$@"
23+
fi
24+
else
25+
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
26+
fi

docker/8.4/supervisord.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[supervisord]
2+
nodaemon=true
3+
user=root
4+
logfile=/var/log/supervisor/supervisord.log
5+
pidfile=/var/run/supervisord.pid
6+
7+
[program:php]
8+
command=%(ENV_SUPERVISOR_PHP_COMMAND)s
9+
user=%(ENV_SUPERVISOR_PHP_USER)s
10+
environment=LARAVEL_SAIL="1"
11+
stdout_logfile=/dev/stdout
12+
stdout_logfile_maxbytes=0
13+
stderr_logfile=/dev/stderr
14+
stderr_logfile_maxbytes=0
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
mysql --user=root --password="$MYSQL_ROOT_PASSWORD" <<-EOSQL
4+
CREATE DATABASE IF NOT EXISTS testing;
5+
GRANT ALL PRIVILEGES ON \`testing%\`.* TO '$MYSQL_USER'@'%';
6+
EOSQL

exampleApp/.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

exampleApp/.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto eol=lf
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
10+
CHANGELOG.md export-ignore
11+
.styleci.yml export-ignore

exampleApp/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/.phpunit.cache
2+
/node_modules
3+
/public/build
4+
/public/hot
5+
/public/storage
6+
/storage/*.key
7+
/storage/pail
8+
/vendor
9+
.env
10+
.env.backup
11+
.env.production
12+
.phpactor.json
13+
.phpunit.result.cache
14+
Homestead.json
15+
Homestead.yaml
16+
npm-debug.log
17+
yarn-error.log
18+
/auth.json
19+
/.fleet
20+
/.idea
21+
/.nova
22+
/.vscode
23+
/.zed

0 commit comments

Comments
 (0)