Dockerize
If you already install the badaso not from curl way and you want to dockerize your badaso application, here's the step :
- Create directory docker and go to directory docker.
mkdir dockercd docker
- Create file Dockerfile. Dockerfile is a text-based instruction script used to create container images.
sudo nano Dockerfile
- You can copy script to Dockerfile file.
FROM ubuntu:22.04
LABEL maintainer="Taylor Otwell"
ARG WWWGROUPARG NODE_VERSION=16ARG POSTGRES_VERSION=14
WORKDIR /var/www/html
ENV DEBIAN_FRONTEND noninteractiveENV 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 \ && echo "keyserver hkp://keyserver.ubuntu.com:80" >> ~/.gnupg/dirmngr.conf \ && gpg --recv-key 0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c \ && gpg --export 0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c > /usr/share/keyrings/ppa_ondrej_php.gpg \ && echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ && apt-get update \ && apt-get install -y php8.1-cli php8.1-dev \ php8.1-pgsql php8.1-sqlite3 php8.1-gd \ php8.1-curl \ php8.1-imap php8.1-mysql php8.1-mbstring \ php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap \ php8.1-intl php8.1-readline \ php8.1-ldap \ php8.1-msgpack php8.1-igbinary php8.1-redis php8.1-swoole \ php8.1-memcached php8.1-pcov php8.1-xdebug \ && php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \ && curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \ && apt-get install -y nodejs \ && npm install -g npm \ && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarn.gpg >/dev/null \ && echo "deb [signed-by=/usr/share/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \ && curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/pgdg.gpg >/dev/null \ && echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ && apt-get update \ && apt-get install -y yarn \ && apt-get install -y mysql-client \ && apt-get install -y postgresql-client-$POSTGRES_VERSION \ && 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/php8.1
RUN groupadd --force -g $WWWGROUP sailRUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
COPY start-container /usr/local/bin/start-containerCOPY supervisord.conf /etc/supervisor/conf.d/supervisord.confCOPY php.ini /etc/php/8.1/cli/conf.d/99-sail.iniRUN chmod +x /usr/local/bin/start-container
RUN mkdir -p /var/www/html/storageRUN mkdir -p /var/www/html/public RUN chmod -R 777 /var/www/html/storageRUN chmod -R 755 /var/www/html/publicEXPOSE 8000
ENTRYPOINT ["start-container"]
after that, you can save.
- Create file supervisord.conf.
sudo nano supervisord.conf
- You can copy script to supervisord.conf file.
[supervisord]nodaemon=trueuser=rootlogfile=/var/log/supervisor/supervisord.logpidfile=/var/run/supervisord.pid
[program:php]command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan octane:start --server=swoole --host=0.0.0.0 --port=8000user=sailenvironment=LARAVEL_SAIL="1"stdout_logfile=/dev/stdoutstdout_logfile_maxbytes=0stderr_logfile=/dev/stderrstderr_logfile_maxbytes=0
after that, you can save.
- Create file start-container.
sudo nano start-container
- You can copy script to start-container file.
if [ ! -z "$WWWUSER" ]; then usermod -u $WWWUSER sailfi
if [ ! -d /.composer ]; then mkdir /.composerfi
chmod -R ugo+rw /.composer
if [ $# -gt 0 ]; then exec gosu $WWWUSER "$@"else exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conffi
after that, you can save.
- Create file php.ini.
sudo nano php.ini
- You can copy script to php.ini file.
[PHP]post_max_size = 100Mupload_max_filesize = 100Mvariables_order = EGPCS
after that, you can save.
- Go to directory project and create file docker-compose.yml
version: '3'services: badaso: build: context: ./docker/8.1 dockerfile: Dockerfile args: WWWGROUP: '${WWWGROUP}' image: badaso extra_hosts: - 'host.docker.internal:host-gateway' ports: - '${APP_PORT:-8000}:8000' - '${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}' volumes: - '.:/var/www/html' networks: - sail depends_on: - mysql - redis 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 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: 5snetworks: sail: driver: bridgevolumes: sail-mysql: driver: local sail-redis: driver: local
#
Run DockerGo to directory project.
Copy .env.example to .env and change the necessary env variables.
cd /var/www/your-project-namecp .env.example .envnano .env
- Change and add the following variables, as well as other variables that you may have to change such as database, AWS, Redis, mail, pusher configs.
APP_ENV=productionAPP_DEBUG=falseAPP_PORT=8000APP_URL=your-hostname
DB_DATABASE=your-databaseDB_USERNAME=usernameDB_PASSWORD=password
WWWGROUP=1000WWWUSER=1000