Skip to content
This repository was archived by the owner on Apr 1, 2021. It is now read-only.

Commit 7a3f681

Browse files
committed
Merge branch 'feature/docker' into develop
2 parents aef22fc + 784370b commit 7a3f681

File tree

6 files changed

+39
-12
lines changed

6 files changed

+39
-12
lines changed

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ COPY package-lock.json /var/www
88
RUN npm ci
99

1010
COPY . /var/www
11-
RUN npm run prod
11+
# RUN npm run prod
1212
RUN rm -rf /var/www/node_modules/
1313

1414
FROM php:7.2-fpm AS server
@@ -51,6 +51,12 @@ COPY deploy/web/mime.types /etc/nginx/mime.types
5151
COPY deploy/web/php.ini /usr/local/etc/php/php.ini
5252
COPY --from=compiler /var/www /var/www
5353

54+
# Force HTTPS
55+
ARG FORCE_HTTPS=false
56+
RUN if [ ${FORCE_HTTPS} = true ]; then \
57+
sed -i 's/# fastcgi_param HTTPS/fastcgi_param HTTPS/' /etc/nginx/sites-available/default \
58+
;fi
59+
5460
RUN composer dump-autoload --no-dev --optimize
5561
RUN chown -R www-data:www-data /var/www
5662
RUN php artisan config:cache \

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ npm run watch
8484
## or using Hot Module Replacement
8585
npm run hot
8686
```
87-
* Open browser, goto `http://localhost:8080`
87+
* Open browser, goto `http://localhost:8888`
8888

8989
### For Production
9090
* Create and run Container
9191
```
9292
docker-compose up -d prod
9393
```
94-
* Open browser, goto `http://localhost:8888`
94+
* Open browser, goto `http://localhost:88`
9595

9696

9797

deploy/dev/Dockerfile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ RUN set -x \
1313
git \
1414
unzip \
1515
zlib1g-dev \
16-
gnupg
16+
gnupg \
17+
libpng-dev \
18+
vim \
19+
&& apt-get clean
1720

1821
# Install Node
1922
RUN curl --silent --location https://deb.nodesource.com/setup_8.x | bash -
2023
RUN apt-get install --no-install-recommends --no-install-suggests -y \
21-
nodejs
24+
nodejs \
25+
&& apt-get clean
2226

2327
# Install PHP Plugin
2428
RUN docker-php-ext-install zip
@@ -29,6 +33,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
2933
# Install Composer
3034
ENV COMPOSER_ALLOW_SUPERUSER=1
3135
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
36+
RUN composer config -g repos.packagist composer https://packagist.jp
3237
RUN composer global require hirak/prestissimo
3338

3439
# Configuring NGINX
@@ -37,8 +42,18 @@ COPY deploy/web/nginx.conf /etc/nginx/nginx.conf
3742
COPY deploy/web/mime.types /etc/nginx/mime.types
3843
COPY deploy/web/php.ini /usr/local/etc/php/
3944

45+
# Force HTTPS
46+
ARG FORCE_HTTPS=false
47+
RUN if [ ${FORCE_HTTPS} = true ]; then \
48+
sed -i 's/# fastcgi_param HTTPS/fastcgi_param HTTPS/' /etc/nginx/sites-available/default \
49+
;fi
50+
51+
# Cleanup
4052
RUN rm -rf /var/www/html/
4153

4254
EXPOSE 80 443 8080
4355

56+
ENV MIX_HMR_HOST=0.0.0.0
57+
ENV MIX_HMR_PORT=8080
58+
4459
CMD service nginx start && php-fpm

deploy/web/site.conf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ server {
44
error_log /var/log/nginx/error.log;
55
access_log /var/log/nginx/access.log;
66

7-
root $root_path;
7+
root $root_path;
88
index index.php;
9+
server_name _;
910

1011
add_header X-Frame-Options "SAMEORIGIN";
1112
add_header X-XSS-Protection "1; mode=block";
@@ -31,7 +32,7 @@ server {
3132
fastcgi_pass 127.0.0.1:9000;
3233
fastcgi_split_path_info ^(.+\.php)(/.+)$;
3334
fastcgi_intercept_errors on;
34-
fastcgi_param HTTPS on;
35+
# fastcgi_param HTTPS on;
3536
fastcgi_param PATH_INFO $fastcgi_path_info;
3637
fastcgi_param SCRIPT_FILENAME $root_path$fastcgi_script_name;
3738
}

docker-compose.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
version: '3'
22
services:
33
prod:
4-
build: ./
4+
build:
5+
context: ./
6+
args:
7+
- FORCE_HTTPS=false
58
ports:
6-
- 8888:80
9+
- 88:80
710
dev:
811
build:
912
context: ./
1013
dockerfile: deploy/dev/Dockerfile
14+
args:
15+
- FORCE_HTTPS=false
1116
volumes:
1217
- ./:/var/www
1318
ports:
19+
- 8888:80
1420
- 8080:8080
15-
- 8000:80

webpack.mix.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ mix.extract([
8484

8585
mix.options({
8686
hmrOptions: {
87-
host: '0.0.0.0',
88-
port: 8080,
87+
host: process.env.MIX_HMR_HOST,
88+
port: process.env.MIX_HMR_PORT,
8989
},
9090
uglify: { parallel: true },
9191
})

0 commit comments

Comments
 (0)