質問編集履歴

2

ファイル内容の記載

2020/01/15 11:32

投稿

keijiokita
keijiokita

スコア11

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  cloud9でamazon linuxをEC2インスタンスで使用し、dockerでlaravelの環境構築を行いました。
6
6
 
7
-
7
+ dockerに関しては初心者です。
8
8
 
9
9
  フォルダ構成:
10
10
 

1

ファイルの内容

2020/01/15 11:32

投稿

keijiokita
keijiokita

スコア11

test CHANGED
File without changes
test CHANGED
@@ -40,13 +40,151 @@
40
40
 
41
41
 
42
42
 
43
+
44
+
45
+ docker-compose.yml
46
+
47
+ ```
48
+
49
+ FROM php:7.2-fpm
50
+
51
+ COPY php.ini /usr/local/etc/php/
52
+
53
+
54
+
55
+ RUN apt-get update \
56
+
57
+ && apt-get install -y zlib1g-dev mariadb-client \
58
+
59
+ && docker-php-ext-install zip pdo_mysql
60
+
61
+
62
+
63
+ #Composer install
64
+
65
+ RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
66
+
67
+ RUN php -r "if (hash_file('sha384', 'composer-setup.php') === 'c5b9b6d368201a9db6f74e2611495f369991b72d9c8cbd3ffbc63edff210eb73d46ffbfce88669ad33695ef77dc76976') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
68
+
69
+ RUN php composer-setup.php
70
+
71
+ RUN php -r "unlink('composer-setup.php');"
72
+
73
+ RUN mv composer.phar /usr/local/bin/composer
74
+
75
+
76
+
77
+ ENV COMPOSER_ALLOW_SUPERUSER 1
78
+
79
+
80
+
81
+ ENV COMPOSER_HOME /composer
82
+
83
+
84
+
85
+ ENV PATH $PATH:/composer/vendor/bin
86
+
87
+
88
+
89
+
90
+
91
+ WORKDIR /var/www
92
+
93
+
94
+
95
+ RUN composer global require "laravel/installer"
96
+
97
+ ```
98
+
99
+ docker-compose.yml
100
+
101
+ ```
102
+
103
+ version: '3'
104
+
105
+
106
+
107
+ services:
108
+
109
+ php:
110
+
111
+ container_name: php
112
+
113
+ build: ./docker/php
114
+
115
+ volumes:
116
+
117
+ - ./server:/var/www
118
+
119
+
120
+
121
+ nginx:
122
+
123
+ image: nginx
124
+
125
+ container_name: nginx
126
+
127
+ ports:
128
+
129
+ - 80:80
130
+
131
+ volumes:
132
+
133
+ - ./server:/var/www
134
+
135
+ - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
136
+
137
+ depends_on:
138
+
139
+ - php
140
+
141
+
142
+
143
+ db:
144
+
145
+ image: mysql:5.7
146
+
147
+ container_name: db-host
148
+
149
+ environment:
150
+
151
+ MYSQL_ROOT_PASSWORD: root
152
+
153
+ MYSQL_DATABASE: database
154
+
155
+ MYSQL_USER: docker
156
+
157
+ MYSQL_PASSWORD: docker
158
+
159
+ TZ: 'Asia/Tokyo'
160
+
161
+ command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
162
+
163
+ volumes:
164
+
165
+ - ./docker/db/data:/var/lib/mysql
166
+
167
+ - ./docker/db/my.cnf:/etc/mysql/conf.d/my.cnf
168
+
169
+ - ./docker/db/sql:/docker-entrypoint-initdb.d
170
+
171
+ ports:
172
+
173
+ - 3306:3306
174
+
175
+
176
+
177
+ ```
178
+
43
179
  ```
44
180
 
45
181
  docker-compose exec php bash
46
182
 
183
+
184
+
185
+ #PHPコンテナに入った後
186
+
47
- ```
187
+ ```
48
-
49
- PHPコンテナに入った後
50
188
 
51
189
  ```
52
190