Skip to content

Instantly share code, notes, and snippets.

@wantonbe
Last active March 10, 2020 22:26
Show Gist options
  • Save wantonbe/a817c715b6bb7e0e0eadd985637eceba to your computer and use it in GitHub Desktop.
Save wantonbe/a817c715b6bb7e0e0eadd985637eceba to your computer and use it in GitHub Desktop.
Dockerハンズオン

mkdir docker-handson && cd docker-handson mkdir src laravel

#!/bin/bash
docker run -v `pwd`/src:/src composer create-project --prefer-dist laravel/laravel src/$1

chmod +x install.sh; /bin/bash install.sh mylaravel

FROM php:7.2-apache
RUN set -x && \
apt-get -y update && \
apt-get install -y mysql-client net-tools curl zlib1g-dev unzip
RUN \
docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-configure mysqli --with-mysqli=mysqlnd --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-install mysqli \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-install zip \
&& pecl install xdebug
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
RUN a2enmod rewrite
WORKDIR /var/www
version: '3.1'
services:
app:
build:
context: ./laravel
volumes:
- ./src:/var/www
ports:
- "8080:80"
working_dir: /var/www/mylaravel
environment:
APACHE_DOCUMENT_ROOT: /var/www/mylaravel/public
links:
- mysql
mysql:
image: mysql:5.7
ports:
- "3306:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
TZ: "Asia/Tokyo"
docker-compose up -d
ブラウザでアクセス
http://localhost:8080
@wantonbe
Copy link
Author

wantonbe commented Apr 4, 2019

ファイル構成はこうです

+ docker-handson
  +-- src
  +-- laravel
       +-- Dockerfile
  +-- install.sh
  +-- docker-compose.yaml

@wantonbe
Copy link
Author

wantonbe commented Apr 4, 2019

Windows ユーザーの方は pwd の部分は自分のディレクトリ名に変更してください

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment