diff --git a/.env.example b/.env.example index 91bfa01..0b71ae6 100644 --- a/.env.example +++ b/.env.example @@ -6,15 +6,17 @@ APP_URL=http://localhost LOG_CHANNEL=stack +DB_HOST_READ=host.docker.internal + DB_CONNECTION=mysql -DB_HOST=127.0.0.1 +DB_HOST=host.docker.internal DB_PORT=3306 DB_DATABASE=laravel DB_USERNAME=root DB_PASSWORD= BROADCAST_DRIVER=log -CACHE_DRIVER=file +CACHE_DRIVER=redis QUEUE_CONNECTION=sync SESSION_DRIVER=file SESSION_LIFETIME=120 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3bf2c87 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,41 @@ +# For more information: https://laravel.com/docs/sail +version: '3' +services: + karudhaas: + build: + context: ./docker/7.4 + dockerfile: Dockerfile + args: + WWWGROUP: '${WWWGROUP}' + image: sail-8.0/app + ports: + - '${APP_PORT:-80}:80' + environment: + WWWUSER: '${WWWUSER}' + LARAVEL_SAIL: 1 + volumes: + - '.:/var/www/html' + networks: + - sail + - docker + redis: + image: 'redis:alpine' + ports: + - '${FORWARD_REDIS_PORT:-6379}:6379' + volumes: + - 'sailredis:/data' + networks: + - docker + - sail + +networks: + sail: + driver: bridge + docker: + external: true + +volumes: + sailmysql: + driver: local + sailredis: + driver: local diff --git a/docker/7.4/Dockerfile b/docker/7.4/Dockerfile new file mode 100644 index 0000000..019f335 --- /dev/null +++ b/docker/7.4/Dockerfile @@ -0,0 +1,56 @@ +FROM ubuntu:20.04 + +LABEL maintainer="Taylor Otwell" + +ARG WWWGROUP + +WORKDIR /var/www/html + +ENV DEBIAN_FRONTEND noninteractive +ENV TZ=UTC + +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN apt-get update \ + && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \ + && mkdir -p ~/.gnupg \ + && chmod 600 ~/.gnupg \ + && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \ + && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C \ + && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C \ + && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu focal main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ + && apt-get update \ + && apt-get install -y php7.4-cli php7.4-dev \ + php7.4-pgsql php7.4-sqlite3 php7.4-gd \ + php7.4-curl php7.4-memcached \ + php7.4-imap php7.4-mysql php7.4-mbstring \ + php7.4-xml php7.4-zip php7.4-bcmath php7.4-soap \ + php7.4-intl php7.4-readline php7.4-pcov \ + php7.4-msgpack php7.4-igbinary php7.4-ldap \ + php7.4-redis \ + && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \ + && curl -sL https://deb.nodesource.com/setup_15.x | bash - \ + && apt-get install -y nodejs \ + && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ + && echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \ + && apt-get update \ + && apt-get install -y yarn \ + && apt-get install -y mysql-client \ + && apt-get install -y postgresql-client \ + && apt-get -y autoremove \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +RUN setcap "cap_net_bind_service=+ep" /usr/bin/php7.4 + +RUN groupadd --force -g $WWWGROUP sail +RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail + +COPY start-container /usr/local/bin/start-container +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf +COPY php.ini /etc/php/7.4/cli/conf.d/99-sail.ini +RUN chmod +x /usr/local/bin/start-container + +EXPOSE 8000 + +ENTRYPOINT ["start-container"] \ No newline at end of file diff --git a/docker/7.4/php.ini b/docker/7.4/php.ini new file mode 100644 index 0000000..4d70973 --- /dev/null +++ b/docker/7.4/php.ini @@ -0,0 +1,4 @@ +[PHP] +post_max_size = 100M +upload_max_filesize = 100M +variables_order = EGPCS \ No newline at end of file diff --git a/docker/7.4/start-container b/docker/7.4/start-container new file mode 100644 index 0000000..0d53a61 --- /dev/null +++ b/docker/7.4/start-container @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +if [ ! -z "$WWWUSER" ]; then + usermod -u $WWWUSER sail +fi + +if [ ! -d /.composer ]; then + mkdir /.composer +fi + +chmod -R ugo+rw /.composer + +if [ $# -gt 0 ];then + exec gosu $WWWUSER "$@" +else + /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf +fi \ No newline at end of file diff --git a/docker/7.4/supervisord.conf b/docker/7.4/supervisord.conf new file mode 100644 index 0000000..731b183 --- /dev/null +++ b/docker/7.4/supervisord.conf @@ -0,0 +1,14 @@ +[supervisord] +nodaemon=true +user=root +logfile=/var/log/supervisor/supervisord.log +pidfile=/var/run/supervisord.pid + +[program:php] +command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80 +user=sail +environment=LARAVEL_SAIL="1" +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 \ No newline at end of file