Skip to content

Instantly share code, notes, and snippets.

@autotrof
Last active June 29, 2023 23:54
Show Gist options
  • Save autotrof/2c48789ae4be1146b191da765b620392 to your computer and use it in GitHub Desktop.
Save autotrof/2c48789ae4be1146b191da765b620392 to your computer and use it in GitHub Desktop.
docker for laravel project

#CARA PAKAI

  1. Pastikan sudah terinstall docker
  2. buat file Dockerfile di root folder project laravel. isinya seperti di atas
  3. buat docker-compose.yml taruh di root folder project laravel. isinya seperti di atas
  4. pastikan .env diseting dengan betul (DB_HOST=mariadb, DB_USERNAME=root, DB_PASSWORD=agungganteng, DB_PORT=3306)
  5. run docker-compose up -d
version: '3.9'
services:
web:
build: .
ports:
- "8000:80"
volumes:
- ./:/app
adminer:
container_name: adminer
image: adminer
restart: unless-stopped
ports:
- 8080:8080
environment:
- ADMINER_PLUGINS=tinymce dump-json dump-xml dump-zip dump-alter tables-filter
- ADMINER_DESIGN=pappu687
mariadb:
container_name: mariadb
image: mariadb
environment:
- MARIADB_ROOT_PASSWORD=agungganteng
ports:
- 3306:3306
volumes:
- ./mariadb:/var/lib/mysql
restart: unless-stopped
FROM webdevops/php-nginx:8.2
LABEL maintainer [email protected]
RUN apt update
RUN apt install nano wget curl -y
RUN touch ~/.bashrc && chmod +x ~/.bashrc
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
RUN mv /bin/sh /bin/sh.bak && ln -s /bin/bash /bin/sh
RUN . ~/.nvm/nvm.sh && source ~/.bashrc && nvm install --lts
RUN rm /bin/sh && mv /bin/sh.bak /bin/sh
WORKDIR /app
ENV PHP_DATE_TIMEZONE=Asia/Jakarta
ENV COMPOSER_VERSION=2
ENV PHP_DISMOD=ioncube,amqp,calendar,vips,filter,sockets
ENV WEB_DOCUMENT_ROOT=/app/public
#cronjob for laravel
RUN (crontab -l ; echo "* * * * * cd /app && php artisan schedule:run >> /dev/null 2>&1") | crontab -
EXPOSE 80
EXPOSE 443
EXPOSE 22
EXPOSE 5173
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment